在我的jquery函数中,我有一个加载器gif图像.在我显示它之后,我想延迟一秒钟,然后继续执行其余的代码.我怎样才能做到这一点?
$('#loader').css('display', '');
//// I want to put here a delay.
var myDate = new Date();
myDate.setFullYear(2013,8,2);
var checkyear = myDate.getFullYear();
var monthly =myDate.getMonth();
var daily =myDate.getDate();
$('#day').html(daily) ;
$('#month').html(months[monthly]) ;
$('#year').html(checkyear) ;
Run Code Online (Sandbox Code Playgroud) 在我的页面中,我有三个单选按钮,我想在单击时检查单选按钮<li>.我的点击功能正在运行,但点击时未检查收音机.我怎样才能做到这一点?我的代码如下
$(document).ready(function() {
$('#myContainer li').click(function() {
$('#radio1').attr('checked');
});
});
<div id="myContainer">
<li id="li1">
<input id="radio1" name="RadioGroup" value="val1" type="radio">
val1
</li>
<li id="li2">
<input id="radio2" name="RadioGroup" value="val2" type="radio">
val2
</li>
<li id="li3">
<input id="radio3" name="RadioGroup" value="val3" type="radio">
val3
</li>
</div>
Run Code Online (Sandbox Code Playgroud) 我有两个 div,如下所示,我想从 div top2 更改 span s1 的类名。但是下面的代码不起作用。我怎样才能做到这一点?
$('#top1 #s1 span.myclass-old').toggleClass('myclass-new');
<div id="top1">
<span id="s1" class="myclass">a</span>
<span id="s2" class="myclass">b</span>
</div>
<div id="top2">
<span id="s1" class="myclass-old">a</span>
<span id="s2" class="myclass">b</span>
</div>
Run Code Online (Sandbox Code Playgroud) 我在页面中有邻居,我想禁用它.有办法吗?我的代码如下
<script type="text/javascript">
$(document).ready(function() {
var myButton = $(this, "input[type='button']");
$(myButton).attr("disabled", "true");
});
</script>
<input id="create" class="button" type="button" >
Run Code Online (Sandbox Code Playgroud)