gpt4 book ai didi

jquery - 是 :checked not working while using Jquery 1. 7

转载 作者:行者123 更新时间:2023-12-01 06:49:53 24 4
gpt4 key购买 nike

看看这个简单的代码

<小时/>

html

<input type="checkbox" id="check" >&nbsp;<span id="rm">Remember
me</span> <span id="ok">Okay!</span>

CSS

#ok{
position:absolute;
font:italic bold 14px century;
color:green;
margin-left:3px;
margin-top:2px;
display:inline-block;
opacity:0;
}

Jquery

if($('#check').is(":checked"))
{
$("#ok").css("opacity",1);
}

http://jsfiddle.net/milanshah93/4Hf9T/

当我选中该框时,它不起作用。

最佳答案

页面加载时未选中您的复选框。虽然你可以做这样的事情 -

$("#check").on('change', function () {
if ($(this).is(":checked")) {
$("#ok").css("opacity", 1);
}
else{
$("#ok").css("opacity", 0);
}
});

DEMO

关于jquery - 是 :checked not working while using Jquery 1. 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16545258/

24 4 0
文章推荐: tsql - 与正常的行集相比,FOR XML AUTO 子句能否给出意想不到的结果?
文章推荐: python - 如何为Python指定虚拟环境
文章推荐: java - 读取文件并映射到 Map>
文章推荐: jquery - 如何使用 jQuery 使
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com