Can I use JavaScript to set the 'name' attribute?

前端 未结 7 583
时光取名叫无心
时光取名叫无心 2020-12-11 16:56

According to SitePoint (and my own experiments), the IE implementation of \"setAttribute()\" is buggy and unreliable.

Also according to SitePoint, the name

相关标签:
7条回答
  • 2020-12-11 17:28

    This worked for me

    alert(document.getElementById('testInput').name);
    document.getElementById('testInput').name = 'someName';
    alert(document.getElementById('testInput').name);
    

    With

    <input type="radio" name="test" id="testInput" />
    
    0 讨论(0)
提交回复
热议问题