Tuesday, 29 January 2013 13:55

Getting the element Id that fired an event using JQuery

Written by 
Rate this item
(0 votes)

you may want to get the asp.net control's or html element's
id when clicked or other events fired for that element.
It can be done in many ways using jquery or simple javascript.

here i wrote one simple way to that..when element clicked a javascript
function will be called.in this function we get the id this way -

function Mitsol_CommentAdd(caller) {
var id = caller.id; // id will store the id
var newid = id.split("_");
if (newid[2] == "submit") { } //do task
}

in page - asp.net control look like below -

<asp:Button ID='Mitsol_Submit_Button' OnClientClick="Mitsol_CommentAdd(this); return false;"
CssClass="button bigrounded blue" runat="server" resourcekey="Submit Comment"/>

for html element you will use click instead OnClientClick.

Read 1838 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments