<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'));
}
});
问候亚光