jquery - if i have 5 buttons with same CLASS, can i use javascript onclick to get ID? -


i have 5 buttons set same class "deletebutton"

but each deleton button has unique purpose ( delete different id )

$(".deletebutton").click(function (e){     document.getelementbyid("abc").href="delete.php?adid="; + id of button clicked }); 

what need modify link of button, based on id of button clicked.

<a  id="delete" href="remove.php?adid=" >confirm</a> 

i have been having issue this, , think because "deletebutton" function running off class of button knows class not id of specifc button clicked? thoughts?

you can use of these id this.id or e.target.id or $(this).attr("id")

$(".deletebutton").click(function (e){     document.getelementbyid("abc").href="delete.php?"+ this.id; }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -