nur*_*lam 1 ajax jquery jquery-selectors
评论的回复工作正常,但我想做类似的事情,$('#total_products').attr('value') = response;但这不起作用.为什么这不起作用,我该如何解决?
$(document).ready(function(){
$.ajax({
type : 'post',
url : 'product_store.php',
data : {
total_products: "totalproducts"
},
success:function(response) {
$('#total_products').attr('value') = response;
/*document.getElementById("total_products").value=response;*/
}
});
})
Run Code Online (Sandbox Code Playgroud)
小智 6
虽然上面的解决方案是正确的,但在jQuery中执行此操作的常规方法是:
$('#total_products').val(response);
Run Code Online (Sandbox Code Playgroud)