Select diffirent elements from parent by jQuery -
i learning developing, , have question jquery. have code here:
<div id="name_1"> <p class="my_p">i need value too</p> <a href="#" class="my_link">click me value of <p> tag</a> </div>
yes, question in link: how can value of <p>
tag in it's parent after clicked link? tryed code this, not work:
$(document).ready(function(){ $('.my_link').click(function(){ var get_value = $('.my_p').parent().html(); //returned html codes in <div> var get_value = $('.my_p').parent().text(); //returned texts in <div> }); });
use find() method class text .my_p parent
$(document).ready(function(){ $('.my_link').click(function(){ var get_value = $(this).parent().find('.my_p').text(); }); });
Comments
Post a Comment