All,
I’m using the following code:
$(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);
});
}
}
}
For some reason it always says that my first if statement for:
if($("#other_liked_vendors").val()!="")
Is always coming up false even after I’ve put data in my div with the html. Any idea why it isn’t recognize a value in my div even after I put data in it?
Thanks!
Did you mean to write
as it seems like
"#other_liked_vendors"is adiv. You can use val() only with form elements. You have to use html() or text() for elements like div.