我在 JQuery 中使用类选择器,这工作得很好,但在 IE6 中却失败了,因为它没有应用我想要的宽度。
$('.ui-state-default .ui-jqgrid-hdiv').css('width', width);
如果我尝试一个类,它会起作用吗?但我需要将该宽度应用于具有这两个类的 div。
感谢大家的帮助。
更新
$onselect = <<<loadComplete
function go_size(){
var width = document.documentElement.clientWidth - 45;
$('#gbox_grid').css('width', width);
$('#gview_grid').css('width', width);
$('#pager').css('width', width);
$('.ui-state-default .ui-jqgrid-hdiv').css('width', width);
$('.ui-jqgrid-bdiv').css('width', width)
}
loadComplete;
最佳答案
删除类名称之间的空格。使用您发布的选择器,您可以在父级 .ui-state-default
中搜索子元素 .ui-jqgrid-hdiv
。 p>
看here (W3C)和 here (jQuery)了解如何编写选择器。
此外,请查看 class 属性是否跨越 HTML 源代码中的多行。 IE 6 无法正确处理该问题。
关于javascript - JQuery 多类选择器在 IE6 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3165637/