这是我第一次在这里发布信息,感谢所有可以给我一些建议的人!
<html>
<head>
<style>
</style>
<script src="jquery-1.5.2.js"></script>
</head>
<body>
<div
class="super"
style="
border: solid black 1px;
height:100px;
width:100px;
">
</div>
<div
class="super .eight"
style="
background: blue;
">
</div>
<script>
$(".super").click(function () {
$(this).addClass(" .eight");
});
</script>
</body>
</html>
所以基本上问题是我想在已经定义为super的类上添加例如背景或其他类型的元素。我正在尝试使用子类,但它似乎没有用。
请问我是否还有不清楚的地方,我很抱歉。
最佳答案
没有点(在类名中)。
$(".super").click(function () { $(this).addClass("eight"); });
关于javascript - jQuery addClass添加子类不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5843568/