I think i have done a right thing, I click the button and the paragraph doesn't appear. Can anyone help me why with my jQuery?
$('.open').on('click',function(event){ $(this).nextAll('.ranch').toggle(); }); I think i have done a right thing, I click the button and the paragraph doesn't appear. Can anyone help me why with my jQuery?
$('.open').on('click',function(event){ $(this).nextAll('.ranch').toggle(); }); There is no jquery plugin attached in your html. Please check console for error.
http://codepen.io/SESN/pen/WxxZOg
Here is your answer
$('.open').on('click',function(){ $(this).closest('.content').find('p.ranch').toggle(); }); Lets make this simple
$('.open').on('click',function(){ $('p.ranch').toggle(); }); hope this will work for you
.open is nested in another element, .nextAll() looks for siblings. You'll have to go one level further backwards for that to work.
Here's how I'd find the parent .content, that's just me though:
$('.open').on('click', function(event) { $(this).closest('.content').find('.ranch').toggle(); });
$(this).parent().prev().toggle();also add jQuery library in JSBIN