javascript - Get the closest sibling of the data in a form -
clicking price class "onward" should take data "i want data "
<span class="onward">4518</span> <table> <tr> <td class="select_fly"> <form> want data </form> </td> </tr> </table> $(document).on('click', '.onward', function(){ var owner = $(this).closest('td').siblings('td.select_fly').html(); console.log(owner); });
but me owner coming "undefined" can me how data " want data"
you can use
var owner = $(this).next('table').find('td.select_fly').html();
so js :
$(document).on('click', '.onward', function(){ var owner = $(this).next('table').find('td.select_fly').html(); alert(owner); });
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script> <span class="onward">4518</span> <table> <tr> <td class="select_fly"> <form> want data </form> </td> </tr> </table>
if want have text, then
var owner = $(this).next('table').find('td.select_fly form').html();
this give only
i want data
Comments
Post a Comment