所有, 我使用下面的代碼:獲得股利的價值
$(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