如何删除页面加载时的单选按钮值。单选按钮列表如此动态我必须删除此值<input type="radio" name=myradio value="Null">Null
<input type="radio" name=myradio value="Bill">one
<input type="radio" name=myradio value="Sale">two
<input type="radio" name=myradio value="Null">Null
答案 0 :(得分:1)
你可以试试这个 - 首先制作一个Javascript函数,如:
<script>
function remvalue()
{
document.getElementById('myradiobutton').value="";
}
window.onload=remvalue;
</script>
然后将ID分配给单选按钮:
<input type="radio" id=myradiobutton name=myradio value="Null">Null
答案 1 :(得分:1)
window.onload = function() {
var myradios= document.getElementsByName('myradio'); //Get all myradio elements from document
for (var i = 0; i < myradios.length; i++) { //Loop all myradio elements
if (myradios[i].value == 'Null') { //If value of element == null
myradios[i].parentNode.removeChild(myradios[i].nextSibling); //Removes the "Null"-Text
myradios[i].parentNode.removeChild(myradios[i]); //Removes the radio button
}
}
}
答案 2 :(得分:0)
脚本下方将删除值为null的单选按钮。
$(document).ready(function(){
$("input[type='radio'][name='myradio'][value='Null']").remove();
});