Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to pass id of element to onclick function of it, how can i do this?
Posted

Hi,

Please see following code. Add this in your .aspx page.

JavaScript
$(function () {
                $('#btnid').click(function () {
.....
.....
}})
 
Share this answer
 
like below
JavaScript
$(document).ready(function() {
    $('body').click(function(event) {
        var id  =event.target.id ;
    });
});

Getting the ID of the element that fired an event using jQuery[^]
 
Share this answer
 
onClick="testfun('<%=textbox1.ClientID%>')";

JS

function testfun(id){

var id=id;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900