javascript - Why is this returning undefined? jquery -
i have line <table id='<?= $value['name']?>'>
in php sets id can target.
this table inside <div>
id="god"
.
but when click table has script:
$("#god table").click(function(){ var link = $(this).id; alert(link); });
it alerts undefined
- tell me why is?
my best guess targets <td>
click on $(this)
not sure - , not know how test that.
use following:
var link = this.id;
the jquery object $(this)
not have propery id
.
note: do not use $(this).attr('id')
when can use this.id
way more efficient. also, note id
case sensitive consistent "god" , "god".
Comments
Post a Comment