Html 如何在window.load()上使用javascript禁用CSS类
我想在页面加载时禁用CSS类。我的课程是Html 如何在window.load()上使用javascript禁用CSS类,html,css,razor,Html,Css,Razor,我想在页面加载时禁用CSS类。我的课程是.rtsULmenuLeft: .rtsULmenuLeft { list-style:none; margin: 0; padding: 0; } 需要禁用该样式的所有实例。我该怎么做 在ListStyle图像中,iam使用自定义图像。它正在显示,最后又隐藏起来了。也就是说,它再次显示的是弹痕。我需要有一个自定义的形象出现。谢谢 添加显示:无 .rtsULmenuLeft
.rtsULmenuLeft
:
.rtsULmenuLeft
{
list-style:none;
margin: 0;
padding: 0;
}
需要禁用该样式的所有实例。我该怎么做
在ListStyle图像中,iam使用自定义图像。它正在显示,最后又隐藏起来了。也就是说,它再次显示的是弹痕。我需要有一个自定义的形象出现。谢谢 添加
显示:无
.rtsULmenuLeft
{
list-style:none;
margin: 0;
padding: 0;
display:none
}
以下是您所要求的工作示例:
在示例中:
- 所有的超链接都是黄色的
- 类为rtsULmenuLeft的项目为红色
- 类为rtsULmenuRight的项目为蓝色
如您所见,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');
不使用窗口加载事件的。不使用窗口加载事件的。删除所有类的;)@MichalKlouda通过regexp修复了您是想隐藏元素,还是仅仅删除类?在ListStyle图像iam中使用自定义图像。它正在显示,最后又隐藏起来了。也就是说,它再次显示的是弹痕。我需要有一个自定义的形象出现。谢谢