Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  28] [ 1]  / answers: 1 / hits: 44741  / 10 Years ago, sun, may 4, 2014, 12:00:00

I have the following structure:



<li id=0 class=instruction>
<div class=row1>
title
</div>
<div class=row2 details hidden>
details
</div>
</li>


css for hidden is: display: none



I'd like when user clicked the instruction, then show the details div.



$(document).ready(function () {
$(.instruction).click(function(e){

$(e).find('.details').removeClass(hidden);


});
});


Tried to implement something like above, but doesn't work. any idea?


More From » jquery

 Answers
7

You have written '.instructionRow' but as per the html it should be '.instruction'. And use $(this) to refer to the element that is clicked. And usage of 'on' (https://api.jquery.com/on/) is better...



$(document).ready(function () {
$(.instruction).on('click', function(e){
$(this).find('.details').removeClass(hidden);
});
});

[#71187] Friday, May 2, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emilee

Total Points: 365
Total Questions: 113
Total Answers: 109

Location: Monaco
Member since Fri, Sep 24, 2021
3 Years ago
;