Jquery 输入值属性中的ajax响应
注释响应可以正常工作,但我想做一些类似于Jquery 输入值属性中的ajax响应,jquery,ajax,jquery-selectors,Jquery,Ajax,Jquery Selectors,注释响应可以正常工作,但我想做一些类似于$('#total_products').attr('value')=response但这不起作用。为什么这不起作用,我如何解决它 $(document).ready(function(){ $.ajax({ type : 'post', url : 'product_store.php', data : { total_products: "totalproducts" }, success:fu
$('#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;*/
}
});
})
使用以下命令:
$('#total_products').attr('value',response);
jQuery attr文档:
使用以下方法:
$('#total_products').attr('value',response);
jQuery attr文档:
尽管上述解决方案是正确的,但在jQuery中执行此操作的正常方法是:
尽管上述解决方案是正确的,但在jQuery中执行此操作的正常方法是:
document.getElementById(“总产品”).value(响应)代码>$('total_products').attr('value',response)感谢它的工作。$('total_products').val(response)<代码>文档.getElementById(“总产品”).value(响应)代码>$('total_products').attr('value',response)感谢它的工作。$('total_products').val(response);