I am trying to get which event is occured ::
function getEvent(){
alert(window.event);
}
I am getting below event object. I want it in string to pare. if event onclick event then I want to do the action. how can I get it in string? or how can I convert event object to string?
[object MouseEvent]
I am trying to get which event is occured ::
function getEvent(){
alert(window.event);
}
I am getting below event object. I want it in string to pare. if event onclick event then I want to do the action. how can I get it in string? or how can I convert event object to string?
[object MouseEvent]
Share
Improve this question
asked Oct 17, 2012 at 10:34
AsmitaAsmita
1,1903 gold badges10 silver badges31 bronze badges
1
- Why do you need this? Can you give an example? – Rune FS Commented Oct 17, 2012 at 10:39
5 Answers
Reset to default 7Use the type property. window.event.type
You'd probably want:
function getEvent(){
alert(window.event.type);
}
https://developer.mozilla/en-US/docs/DOM/event.type
you can easily get it by type
like this
function getEvent(){
alert(window.event.type);
}
More info here
http://www.quirksmode/js/events_access.html
http://www.quirksmode/js/events_properties.html
use the type
property to read out the type:
function getEvent(){
alert(window.event.type);
}
Use the event.type
property, for example
<div id="a" onclick="alert(event.type)">Click This</div>
<div id="b">And This</div>
Javascript:
var func = $('#a').attr('onclick');
$('#b').mouseover(function(e) {
func(e)
});
DEMO: http://jsfiddle/4tLms/