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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -