如果它的类等于其他 div 的(编号 2)类值,我想更改 div 容器(编号 1)的值。
首先,我得到 2 号 div 的值:
var classId = $(this).attr('class').split(' ')[1];
它有两个类,第二个是我正在使用的。
接下来,我尝试比较值并更改 div 编号 1 内的数据:
$.ajax(test.base_url + "name/name/" + ID, {
cache: false,
success: function(data, textStatus, jqXHR) {
if ($("#redChar").attr("class") == classId) {
$("#redChar").find('.'+classId).html(data);
}
else {
$("#redChar").html();
}
},
dataType:"html"
});
我做错了什么?