可变比较类名我有类的名字,如在JavaScript
<input class="so os us">
输入元素就是我想要做的是一个变量是否匹配特定的类名,然后做一些事情
$(function(){
var x="os";
var y=$("input").attr("class");
if(x=y){
//since the class name contains the word "os" it has to perform the actions mentioned here
}
});
我不知道如何实现这一点。
打印变量'y'在屏幕上,使用'alert'左右。然后你会看到为什么'x'不匹配'y'。 – Peter