如果使用 JavaScript 选中复选框,如何重定向到特定链接?
我正在这样做,但它对我不起作用..
<input type="checkbox" name="yousendit" id="yousendit" value="1" onselect="return yousendit();"/>
<script type=javascript>
function yousendit()
{
if(document.getElementById('yousendit').checked== "checked")
{
window.location='https://www.yousendit.com/dropbox?dropbox=mydomain';
return false;
}
return true;
}
</script>
请帮忙
您的来源存在一些问题。这是工作版本:
<input type="checkbox" name="yousendit" id="yousendit" value="1" onclick="return yousendit();"/>
<script>
function yousendit(){
if(document.getElementById('yousendit').checked){
window.location='https://www.yousendit.com/dropbox?dropbox=mydomain';
return false;
}
return true;
}
</script>
Changes:
-
onclick
代替onselect
- 复选框'
checked
属性是布尔值
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)