0

This solution does not work for IE9.

I have the following code:

$(document).ready(function() {
      document.getElementById('unsubref').onclick = function() {unsubcribe();}; 
});

and unsubref is:

<div id="unsub">
<h1>Click <a id="unsubref">here</a> to unsubscribe from the mailing service</h1>
</div>

in Chrome, it works just fine. The function unsubscribe is being invoked with alert.

However, in IE9 it does not work!

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Dejell
  • 13,505
  • 40
  • 138
  • 222

2 Answers2

5

Since you are using jQuery I would recommend you using the .click() method to subscribe to the handler:

$(document).ready(function() {
    $('#unsubref').click(unsubcribe); 
});

or using an anonymous function:

$(document).ready(function() {
    $('#unsubref').click(function() {
        alert('unsubscribing ...');
    }); 
});
Darin Dimitrov
  • 994,864
  • 265
  • 3,241
  • 2,902
-1
 $('#unsubref').bind("click", function(){ alert(''); });
Joeri
  • 361
  • 7
  • 11