jQuery live not working in IE8

2019-08-09 05:46发布

问题:

The following works in Firefox 3 and IE 7 but not in IE8.

Given this HTML snippet:

<li><a href="#" class="remove">remove me</a></li>

javascript:

jQuery('.remove').live('click', function(e){
            jQuery(this).parent().remove();
        });

I wish I had an error message to work with but I don't.

How can I get this to work in IE8?

I should also mention that the anchor tag is being generated by prototype version 1.6.0.

UPDATE: This is a bug in Prototype 1.6.0 and is fixed in 1.6.1 See Issue

回答1:

As I mentioned in the question, the anchor tag is being generated by Prototype 1.6.0. This has a bug that generates the class attribute as "className" instead of just "class". jQuery does not recognize the "className" attribute and therefore my code example fails. This was identified as a bug in Prototype in their issue tracking system and was fixed in 1.6.1.