我有一個複選框。它將更新作爲輸入文本框的$('#express')
的值。如果我使用.toggle
而不是.click
,該複選框將被隱藏。jQuery切換刪除輸入類型複選框
切換是我的複選框被刪除或隱藏的原因嗎?
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()'的形式在jQuery 1.8中被棄用,並在1.9中被刪除。你在使用更高版本嗎? –
它從屏幕隱藏元素,並從帖子中刪除數據並獲取請求。 –
至少在你的HTML代碼中沒有任何id##express# –