我遇到了这一点的jQuery的问题。当页面加载时,id_2被隐藏。如果我选中复选框id_1,则什么都不会发生。但是,如果我重新加载页面,则会显示id_2。jquery复选框问题 - 重新加载页面修复它
<head>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"> /script>
</head>
<input id="id_1" type="checkbox" name="ck1">
<input type="text" id="id_2" name="tx1">
<script type="text/javascript">
$(document).ready(function() {
if ($('#id_1').is(':checked')) {
($('#id_2').show());
} else {
($('#id_2').hide());
}
});
和
如果我使用一个按钮
$("#show_button").click(function()
它的工作原理 - ID_2显示/隐藏正确。我可以看到在萤火虫中,当我检查复选框时,选中的值从真/假切换。
我在做什么错?
奥利
有你'script'标签 – david 2012-08-14 20:11:52
嗨语法问题。我已经解决了,但仍然没有喜悦 – Oli 2012-08-14 20:19:28