我想在页面加载时禁用 CSS 类。我有课.rtsULmenuLeft
:
.rtsULmenuLeft
{
list-style:none;
margin: 0;
padding: 0;
}
需要禁用该样式的所有实例。我怎样才能做到这一点?
在 ListStyle Image iam 中使用自定义图像。它正在显示并最终再次隐藏。也就是说,它会再次显示带有项目符号的标记。我需要存在该自定义图像。谢谢。
这是您所要求的工作示例:http: //jsfiddle.net/ALLew/
在示例中:
如您所见,rtsULmenuLeft 类名已被删除,列表显示为黄色。
// Define a function to run on page load.
var loadCheck = function() {
// Cancel the function if the page isn't loaded...
if(document.readyState !== "complete") {
// ... but call it again in 100 milliseconds.
setTimeout(loadCheck, 100);
return;
}
// From here on, the page is loaded.
// Obtain a list of all elements with the particular class name
var elList = document.getElementsByClassName("rtsULmenuLeft");
// Loop over the elements until there are no longer any with the class.
while(elList.length > 0) {
// For each element, remove the class.
elList[0].className = elList[0].className.replace(
/\brtsULmenuLeft\b/, // RegExp of class name in word boundaries
"" // Replace with empty string - remove it.
);
}
};
loadCheck();
使用 jquery:
$('.rtsULmenuLeft').removeClass('rtsULmenuLeft');
添加display:none
.rtsULmenuLeft
{
list-style:none;
margin: 0;
padding: 0;
display:none
}