Pass this element and custom value to event handler - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Pass this element and custom value to event handler

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p onclick="myFunction(this, 'red')">Click me to change my text color.</p>

<script>
function myFunction(elmnt,clr) {//from w w w  . j a v  a2 s  .  co  m
    elmnt.style.color = clr;
}
</script>

</body>
</html>

Related Tutorials