If you want to change the text of the anchor tag, you can do so like this:
$("a").bind("click", function(event) {
$(event.target).text('Changed msg');
});
This can be shorted as this
inside of the event handler will refer to event.target
or what you've bound the function to (the anchor tag). So you can write the above like so:
$("a").bind("click", function() {
$(this).text('Changed msg');
});
You can't simply set values to mutate the document object model (DOM). You need to use methods like text
and html
to tell jQuery what you want to do. You can do so with vanilla JavaScript.
As mentioned in the comments, eventData
is an object you can include to pass long to the event handler. But it can't mutate or change things.