简体   繁体   English

ie7的jQuery不绑定?

[英]ie7 jquery not binding?

I'm trying to bind some click events with jQuery. 我正在尝试使用jQuery绑定一些click事件。 Everything works in Chrome, FF, and (surprisingly IE 6). 一切都可以在Chrome,FF和(令人惊讶的IE 6)中运行。 However, it doesn't work in IE 7/8. 但是,它在IE 7/8中不起作用。 I'm trying to bind 'click' to a label. 我正在尝试将'click'绑定到标签上。 I've tried all of the following and nothing seems to work: 我已经尝试了以下所有方法,但似乎没有任何效果:

$('label').bind('click', function(){
  alert('label clicked');
});

or 要么

$('label').click(function(){
  alert('label clicked');
);

or 要么

// added a class to all labels
$('.label').bind('click', function(){
  alert('label clicked');
});

or 要么

// added a class to all labels
$('.label').click(function(){
  alert('label clicked');
});

In all the browsers I listed, I'll get a nice alert box, EXCEPT IE 7/8. 在我列出的所有浏览器中,我会得到一个不错的警报框,除了IE 7/8。 Is this a jQuery issue, am I missing something, or what? 这是jQuery问题吗?我是否缺少某些内容? I'm really confused because I've never had a problem like this before... 我真的很困惑,因为我以前从未遇到过这样的问题...

You should try using live() instead of bind(). 你应该尝试使用live()而不是bind()。 Also, are you using the latest version of jquery? 另外,您使用的是最新版本的jquery吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM