Saturday 15 June 2013

javascript - jquery attr("onClick") - ie and ff -


Using jquery, I would like to get javascript from the tag's onClick feature.

  & lt; A href = '#' onClick = 'warning ("bu");' / & Gt;  in Firefox:  alert ($ ('a'). Attr ("onClick")) :  Warning ("bu" )  

IE 6/7: alert ($ ('a'). Attr ("onClick")) Shows: function anonymous () {Alert ("bouquet"); Return;}

How can I get javascript in IE 6/7 using 6/7 or jQuery, and how to get a wrapped function? (Or plain javascript)?

FRANCO

How can I get just JavaScript, and The wrapped function, IE 6/7

You generally do not want to rely on string values ​​for inline event handlers (in fact you should usually save inline event handlers. Features Fully working with script to favor binding - especially if you live using jQuery Where this method is ideal). But if you have to, then the workaround DOM method is getAttributeNode .

  var link = $ ('a') [0]; // or any warning (link.getAttributeNode ('onclick').);  

No comments:

Post a Comment