Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
            
                    
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        2年前关闭。
                    
                
        

所以我和几个李有一个像这样的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[]");
    });
}

10-07 13:32
查看更多