javascript - jQuery get link id -
i'm trying id-attribute of dynamic generated table. if click on first link want "editemploee-4".
<table id="example" class="table span12 table-bordered table-hover"> <thead> <tr> <th>firstname</th> <th>lastname</th> <th>edit</th> </tr> </thead> <tbody> <tr> <td>person 1</td> <td>name person 1</td> <td><a href="#" class = "editdialog" id="editemployee-4"><img src="img/edit.png" height="20" /></a></td> </tr> <tr> <td>person 2</td> <td>name person 2</td> <td><a href="#" class = "editdialog" id="editemployee-5"><img src="img/edit.png" height="20" /></a></td> </tr> <tr> <td>person 3</td> <td>name person 3</td> <td><a href="#" class = "editdialog" id="editemployee-47"><img src="img/edit.png" height="20" /></a></td> </tr> </tbody> </table>
i alreay tried code, same id.
var data = $( "a[id][class=editdialog]" ).attr('id');
do have idea how dynamic generated link id?
event delegation:
$(document).on("click", "#example a", function() { console.log(this.id); //id of clicked link });
not sure how of table dynamically generated, typically want use container element rather document
Comments
Post a Comment