I use PHP and jQuery I'm trying to do something like this:
< Code> $ (this + '. My_child_class'). Html ('test');I have a dynamic list of elements and when I click on a button I use "this" to get the current element in the group.
The problem is that I want to get the class "my_child_class" which is somewhere within the current element group. The above jQuery do not work.
The HTML may look like this:
& lt; Div class = "item" & gt; & Lt; Div class = "container" & gt; & Lt; Div class = "my_child_class" & gt; Content & lt; / Div & gt; & Lt; / Div & gt; & Lt; Input type = "submit" / & gt; & Lt; / Div & gt; & Lt; Div class = "item" & gt; & Lt; Div class = "container" & gt; & Lt; Div class = "my_child_class" & gt; Content & lt; / Div & gt; & Lt; / Div & gt; & Lt; Input type = "submit" / & gt; & Lt; / Div & gt;
You should put this code in your work:
$ (document) .ready (function () {$ ("div.item> input"). Tie ('click', function () {$ (this) .prev (). ('My_child_class') .HTML ('test');});});
Here you can find the full solution:
Regards.
Comments
Post a Comment