jquery parent() issue -
i speak english not well, show code , problem right now.
here code:
html:
<td class="yyyy"> <a id="delete" href="#" >anchor</a> </td>
js:
$(function(){ $("a#delete").click(function(e){ e.preventdefault(); var s = $(this).parent("td").attr("class"); alert(s); }); });
it returns alert "undefined". think must "yyyy".
can me?
thanks! http://jsfiddle.net/nguyenthanh/weayw/4/
i fixed problem write html content of table (tr,td). again!
<table> <tr> <td class="yyyy"> <a id="delete" href="#" >anchor</a> </td> </tr> </table> $(function(){ $("a#delete").click(function(e){ var s = $(this).parent("td").attr("class"); alert(s); e.preventdefault(); }); });
you can't have <td>
in fiddle, should enclosed within <table>
, <tr>
:
<table> <tr> <td class="yyyy"> <a id="delete" href="#">anchor</a> </td> </tr> </table>
try one:
$("a#delete").click(function (e) { var s = $(this).parent("td").attr("class"); alert(s); e.preventdefault(); });
Comments
Post a Comment