I want to have onClick() event on <h1> to <h6>
(any of heading tags) for running some javascript. Please give me some example to have onClick() event in <h1>
which shows some alert() message.
Thanks :)
It's called the inline event registration model. And yes, you can do more or less what you're asking after.
But please don't do this.
It's ancient and reliable, yes. But the drawback is that it requires you to put your JS behaviors into your XHTML structure.
You are much better off using the following idiom:
element.onclick = doSomething;
In jQuery, this might look something like:
$(":header").click(function(){
alert('Handler for .click() called.')
});
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With