jquery - Action item you just clicked -
i have example: fiddle
currently when click on title content appears items have class "title" in css. want item clicked.
how can solve problem?
importantly, want remain same class name.
code html:
<div class="title">title 1 <p style="display:none;">content 1</p> </div> <div class="title">title 2 <p style="display:none;">content 2</p> </div>
code javascript:
jquery(document).ready(function($) { $(document).ready(function() { $(".title").click(function() { $("p").slidetoggle("slow"); }); }) });
edit:
$(document).ready(function(){ $(".titlu").click(function(){ $(this).find$(".top").slidetoggle("slow"); //here think there syntax error }); });
how make connection there "find"?
http://fetr.zonedesign.ro/programe-optionale/
here try implement example. if click on headline nothing happens although done (i think)
you need use $.fn.find()
get descendants of each element in current set of matched elements, filtered selector, jquery object, or element.
code
$(".title").click(function () { $(this).find("p").slidetoggle("slow"); //or, $("p", this).slidetoggle("slow"); });
you can use $.fn.children()
, .children()
method differs .find()
in .children()
travels single level down dom tree while .find()
can traverse down multiple levels select descendant elements (grandchildren, etc.) well.
also, should use 1 document-ready handler.
jquery(document).ready(function ($) { $(".title").click(function () { $(this).find("p").slidetoggle("slow"); }); });
Comments
Post a Comment