所以我有一个有几个像这样的 li 的 ol:
<ol id="monday">
<li id="zero1"><input type="hidden" name="mo[]" value="cero1"><button type="button"">15</button></li>
</ol>
<button type="button" onclick="update()"> Update</button>
我可以更改 ol 的内容,但是当我尝试使用 jquery 更改 name 属性时,它保持不变,我的函数有问题吗?
function update(){
$("#monday input").each(function (){
$("this").attr("name", "mo[]");
});
}
最佳答案
this
是一个关键字,此处不应该是字符串
function update(){
$("#monday input").each(function (){
$(this).attr("name", "mo[]");
});
}
关于javascript - 为什么我无法更改此输入的名称属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50801729/