相邻的兄弟选择器不能在IE7 / 8中动态添加类 [英] Adjacent sibling selector not working with dynamically added class in IE7/8

查看:119
本文介绍了相邻的兄弟选择器不能在IE7 / 8中动态添加类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<span id='span1'>span1</span>
<span>span2</span>
<button id='btn'>select span1</button>

#span1.selected + span {
    background-color:red;
}

$('#btn').click(function() {
    $('#span1').addClass('selected');
});

http://jsfiddle.net/xSGh5/

我使用相邻的同级选择器来为自定义图片设置复选框,因此我不会想放弃这个选择器。任何解决方法?

I'm using adjacent sibling selector to style checkbox with the custom image, so I don't want to abandon this selector. Any workarounds?

推荐答案

这是一个已知的错误,请参阅 + selector here: http://www.quirksmode.org/css/contents.html

Well, this is a known bug, see the section about + selector here: http://www.quirksmode.org/css/contents.html

这篇关于相邻的兄弟选择器不能在IE7 / 8中动态添加类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆