gpt4 book ai didi

jQuery 切换删除输入类型复选框

转载 作者:太空宇宙 更新时间:2023-11-03 21:41:27 27 4
gpt4 key购买 nike

我有一个复选框。它将更新作为输入文本框的 $('#express') 的值。如果我使用 .toggle 而不是 .click,复选框将被隐藏。

切换是我的复选框被删除或不可见的原因吗?

HTML

<form id="addupload" method="post" action="order_history/lightbox/mini-upload-form/upload.php" enctype="multipart/form-data">
<div id="upload">
<div id="drop">
Drop Here
<a>Browse</a>
<input id="uplo" type="file" name="upl" />
</div>
<ul> </ul>
</div>
<div id="formcontent">
<label class="required" for="unitprice" title="Unit price"><input type="text" id="unitprice" name="unitprice" />Unit price</label>
<label class="required" for="qty" title="How many pcs"><input type="text" id="qty" name="qty" />Quanity</label>
<label class="required" for="express" title="Express within China"><input type="text" id="express" name="express" />Express</label>
<label class="required" for="linkURL" title="Insert a full URL http:\\"><input type="text" id="linkURL" name="linkURL" />Link</label>
<label for="yourdesc" title="Describe your need clearly">Description<textarea id="yourdesc" name="yourdesc"></textarea></label>
<label for="shunfeng" title="SF is RMB25 for 1kg ">Express ?<input type="checkbox" id="shunfeng" class="shunfeng" name="shunfeng" /></label>
<label for="formsubmit" class="nocontent" id="uptest"><input type="button" id="submitButton" href="#" class="progress-button" onClick="upload()" value="Add to order" /><strong>Note:</strong> Items marked <img src="order_history/images/required.jpg" alt="Required marker" width="20" height="20" /> are required fields</label>
</div>
</form>

JQUERY

$("#shunfeng").toggle(
function(){
$('#express').val("25");
}, function(){
$('#express').val("0");
}
);

CSS

.shunfeng{
width:15px;
height:15px;}

最佳答案

您正在使用的函数 $.toggle(fn, fn);jQuery 1.8 中已弃用并在 jQuery 1.9 中删除/p>

而且我认为你需要change事件

$("#shunfeng").change(function () {
if(this.checked) {
$('#express').val("25"); //If checked set value to 25
} else {
$('#express').val("0"); //If unchecked set value to 0
}
});

关于jQuery 切换删除输入类型复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23263383/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com