禁用输入标签并专注于提交按钮
我在这里有一个代码,用于禁用表单上的收音机,并在计时器到期后立即关注提交按钮。但是这段代码似乎不起作用。你能告诉我我的代码有什么问题,或者如果你有其他选择吗?我使用jQuery插件timeTo作为我的定时器..禁用输入标签并专注于提交按钮
<script type="text/javascript">
$(document).ready(function() {
$('#countdown').timeTo(5000, disablefocus();
});
});
function disablefocus(){
$(document).ready(function() {
$('input[type=radio]').attr('disabled', true);
$('#submitWidget').focus();
});
</script>
---->
<div id='countdown'></div>
<form>
<input type='radio' name='radio1' value='father'>
<input type = 'submit' id ='submitwidget' value='submit'/>
</form>
你添加额外的花括号为timeTo功能和错过disableFocus功能关闭的大括号。
$(document).ready(function() {
$('#countdown').timeTo(5000, disablefocus);
function disablefocus(){
$('input[type=radio]').attr('disabled', true);
$('#submitWidget').focus();
}
});
或另一种方式
$('#countdown').timeTo(5000, function() { disablefocus(); });
我需要显示时钟滴答,这就是为什么我使用插件。而且,这个像单选按钮这样的小动画会变成灰色,以通知用户它已被禁用? – Nixxhalle
$('#countdown')。timeTo(5000,disablefocus);更换线路并检查 –
您为该场景放置了额外的一个花括号。 –
使用下面的代码,它一定会帮助你
$(document).ready(function() {
$('#countdown').timeTo(5000, function(){
disablefocus();
}
});
});
任何帮助你问,我也面临类似的问题
$(document).ready(function() {
$('#countdown').timeTo(20, function() {
disablefocus();
});
function disablefocus(){
var message = $('#confirmMessage');
var goodColor = "#66cc66";
$('input[type=radio]').attr('disabled', true);
$('#submitWidget').focus();
message.css("color" , goodColor);
message.html("Press me now!");
}
});
你能告诉我什么是timeTo插件的使用。语法是正确的? –
任何改进? –
抱歉,迟到回复。是的,它现在正在工作。但是你能帮我提供一些关于CSS的知识吗?我想将背景更改为灰色,并将一些小动画更改为按钮旁边,表示他需要单击它。 ''你必须点击我吧!'' – Nixxhalle
我试过了,但没有任何反应 '$(document).ready(function(){ $('倒计时 ')timeTo(20,函数(){disablefocus();}); 功能disablefocus(){ VAR消息=的document.getElementById(' #confirmMessage'); VAR goodColor = “#66cc66”; $('input [type = radio]')。attr('disabled',true); $('#submitWidget')。focus(); message.style.color = goodColor; message.innerHTML =“现在按下我!“ } });' – Nixxhalle