Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery find not working

This is my HTML:

        <p class="first">blah blah <a href="" class="more">read more</a></p>
        <div class="read_more">
            <p>more text</p>
        </div>

And javascript:

$(document).ready(function(){
  $('a.more').click(function(){
    $(this).find('.read_more').slideDown();
    return false;
  });
});

Doesn't seem to do anything (read_more is set to display: none) any ideas?

like image 732
fire Avatar asked Dec 13 '22 22:12

fire


1 Answers

Try this:

$(document).ready(function(){ $('a.more').click(function(){ $(this).parent().next().find('.read_more').slideDown(); return false; }); });

Update:

Here is the demo :)

Code:

$(document).ready(function(){
  $('a.more').click(function(){
    $(this).parents().find('.read_more').slideDown('slow');
    return false;
  });
});

You could also do:

$(document).ready(function(){
  $('a.more').click(function(){
    $('.read_more').slideDown('slow');
    return false;
  });
});

Or this:

$(document).ready(function(){
  $('a.more').click(function(){
    $(this).parent().next().slideDown('slow');
    return false;
  });
});
like image 188
Sarfraz Avatar answered Jan 02 '23 01:01

Sarfraz