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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -