<form id="test" onsubmit="return checkParams();" method="post" action="">
<div class="input-inside-label">
<label for="loc">12345</label>
<input class="grab-label" value="" type="text" name="loc" id="loc">
</div>
</form>
我的輸入值爲空。不過,我不希望它被提交爲空。當表單提交時,我希望它抓取標籤的值,然後提交。jquery:獲取標籤值onsubmit
但是我這樣做有很多問題。任何想法我在這裏做錯了嗎?
$('#test').submit(function(e) {
if ($(this).children('.grab-label').val() == '') {
$(this).children('.grab-label').val($(this).closest('label'));
}
});
問候亞光