我有很多使用无法正常工作的旧嵌套列表的 html 页面。我想动态查看页面是否使用它并添加类属性或建议更好的方法。
动态更新所有出现的
<ol type="a"> to <ol class="alpha">
或者建议我是否仍然可以使用该类型但使用嵌入式 CSS 应用样式?
最佳答案
如果你想用 JavaScript 做到这一点,用 jQuery 很容易:
$(document).ready(function(e) {
$('ol[type="a"]').addClass("alpha").removeAttr("type");
});
这会将
- 更改为
- ,方法是选择 ol with type="a",然后添加 alpha 类,然后删除 type 属性。
关于javascript - 将 <ol type ="a"> 的所有出现动态更新为 <ol class ="alpha">,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12625922/