Hi
I want to call 2 different javascript function at a time on mouse click event.
Is there is any possibility to do this
Printable View
Hi
I want to call 2 different javascript function at a time on mouse click event.
Is there is any possibility to do this
Well, you can grab it in a tag. It is called onclick. Or you can set it with JavaScript.
Code:<whatever_tag ... onclick="function(parameters)">
or
<script type="text/javascript">
document.onclick = function();
or
document.getElementById(...).onclick = function();
</script>
Yes there is. Something like thisCode:<input type="text" id="text1" name="text1" onblur="function1(this.value); function2(this.value); function3(this.value); value = "Some Value">
To call two functions at once in the event, you can put them in an anonymous/lambda function (in element attributes you don't have to - it executes JavaScript if it's not a function name):
Note that in anonymous functions, the this keyword loses its scope. This can be solved using the call() method of the Function object:Code:document.onclick = function () { func1(); func2(); };
// - or -
<a href="#" onclick="func1(); func2();">Link</a>
Using this with the above code will now refer to the element object.Code:element.onclick = function () { func1.call(element); func2.call(element); };
Hi guy's
Thank's for u kind help