...

View Full Version : Get Element ID



cheechm
10-19-2008, 09:16 PM
Hi,
I am using jQuery and I want to get the id of the element clicked.

So I do this:
function get_id(id) {
alert(id);
}

<a href="javascript:get_id(this.id);" id="test">Test</a>

That returns "undefined". What is the problem?

Thanks

cheechm
10-19-2008, 10:27 PM
Sorry fixed..
Should be:


function get_id(sid) {
alert(sid.id);
}

<a onclick="get_id(this);" id="test">Test</a>

itsallkizza
10-19-2008, 11:44 PM
so does it work now?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum