I am having trouble targeting all parents with a specific class set.
If I click on George Michael, then I have to say, "Michael" and "George SR" with Below the Dummy HTML and Jacqueline which has failed. I tried to: Edit the request: Also, someone can tell why the above jquery does not work? Please help :) For your use: In this way: & lt; P & gt; want to change the color of the tag.
& lt; Ul & gt; & Lt; Li & gt; & Lt; Div class = "leaf" & gt; & Lt; P & gt; George S & lt; / P & gt; & Lt; / Div & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; Div class = "leaf" & gt; & Lt; P & gt; Michael & lt; / P & gt; & Lt; / Div & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; Div class = "leaf" & gt; & Lt; P & gt; George Michael & lt; / P & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Div class = "leaf" & gt; & Lt; P & gt; Gubbs & lt; / P & gt; & Lt; / Div & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; Div class = "leaf" & gt; & Lt; P & gt; Steve Halt & lt; / P & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Div class = "leaf" & gt; & Lt; P & gt; Lindsey & lt; / P & gt; & Lt; / Div & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; Div class = "leaf" & gt; & Lt; P & gt; Maeby & lt; / P & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
$ (document) .on ("click", '.leaf', Function () {$ (this) .Parents (". Leaf"). Children ('P'). CSS ('color', 'red');});
$ (document) .on ("click ('& gt; .leaf & gt; p'). 'Css' ('color', '' '', '.', 'Red');});
No comments:
Post a Comment