所有, 我使用下面的代码:获得股利的价值
$(document).on('change','.found_other_vendor',function(){
if(checked){
alert("it was checked");
if($("#other_liked_vendors").val()!=""){
alert("second_one");
$.post(ajaxurl, { clicked_id: clicked_id, action: action }, function(results){
$("#other_liked_vendors").append(", " + results);
});
$("#other_liked_vendors")
}else{
alert("first_one");
$.post(ajaxurl, { clicked_id: clicked_id, action: action }, function(results){
$("#other_liked_vendors").html(results);
});
}
}
}
出于某种原因,它总是说,我的第一个if语句为:
if($("#other_liked_vendors").val()!="")
始终是即使我已经将数据放入div的html中,也会出现错误。任何想法为什么它没有认识到我的div值,即使我把数据放进去了?
谢谢!
您只能在表单元素上使用'.val()'。对于其他所有内容,使用'.text()'或'.html()'。 – 2012-02-27 19:46:42