jQuery handling of click event?

0 views
Skip to first unread message

Audrey A Lee

unread,
Aug 21, 2009, 6:51:37 PM8/21/09
to forumgrouper
jQuery People,

Suppose I have this syntax:

$("a.someLinks").click(function(event){tellme();});

I want tellme() to handle the value of href of the clicked link.

What syntax do I put in tellme()?

I got this far:

function tellme() {
// does not work: alert($(this)[0].href);
// does not work: alert($(this)[0].getAttribute("href"));
// This only works in Safari: alert($(this)
[0].event.currentTarget.href);
}

Here is a bigger question:
How would I get this info from the API documentation?

-Audrey

Audrey A Lee

unread,
Aug 22, 2009, 1:10:46 AM8/22/09
to forumgrouper
$("a.someLinks").click(function(event){tellme(this);});

then

function tellme(o) {alert(o.href);}

This is a core JavaScript idea so the API docs might not be a good
place to help with this.

It's more of a cookbook kind of thing.

The main idea is to pass "this" to tellme(o)
Reply all
Reply to author
Forward
0 new messages