I’m writing a script which prevents form clicking, but i can’t make it work in IE7 – 8, maby anyone know why it is?
I try to use ev = e || window.event; but nothing good happens.
Please help, and thanks in future.
(function( button ) {
$( document ).click(function( e ) {
ev = e || event;
var clickedEl = ev.srcElement || ev.target;
var parentClass = $( button ).attr( 'class' ).split(' ')[0];
if ( clickedEl !== button && $( clickedEl ).parents( '.' + parentClass ).
length == 0 && !$( clickedEl ).hasClass( parentClass ) ) {
// DO SOMETHING
}
});
})($('.category_select')[0]);
Because you’re using jQuery, an event object will be passed to the callback, regardless of the browser. Though it’s important to note that you won’t be receiving the “pure” event object: it’s wrapped in a jQuery object. To get the true event object, do this:
That should do the trick, mind you: you won’t have the jQuery
stopPropagationmethod in IE8, you’ll have to correct for that manually by using.returnValue = falseand.cancelBubble = trueThat should work
I also had a look at the jQuery reference this is what it says on the jQuery event object