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,753
  • 72
  • 57
  • 129
Dejell
  • 13,947
  • 40
  • 146
  • 229

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
  • 1,023,142
  • 271
  • 3,287
  • 2,928
-1
 $('#unsubref').bind("click", function(){ alert(''); });
Joeri
  • 361
  • 5
  • 11