jQuery and first element in the clicked element

Posted by user2956944 on Stack Overflow See other posts from Stack Overflow or by user2956944
Published on 2013-11-05T15:44:40Z Indexed on 2013/11/05 15:53 UTC
Read the original article Hit count: 241

Filed under:
|
|

i have 2 div elements, and if i click on the first div then should the other div which is inside of the clicked div displayed, but i can't understand who it works, my jquery code is so:

jQuery('.infobutton').click(function(){
    var clickedID = jQuery(this).attr('id');
    jQuery(clickedID).children('div').toggle(); 
});

<div class="infobutton" id="infobtn1">
    <div class="content">some content</div>
</div>

I get everytime right id, i tried also with .first(), .parent(), .children('.content')

It's possible to do this with jQuery?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery