我正在获取输入框的值并将其作为查询字符串传递给 URL。我不想获取默认值“输入关键字(地址....),它通过以下方式控制显示或隐藏:
//**onClick and OnLostFocus (focus and blur) events on textareas and input textboxes**
$('input[type="text"], textarea').focus(function () {
defaultText = $(this).val();
$(this).val('');
});
$('input[type="text"], textarea').blur(function () {
if ($(this).val() == "") {
$(this).val(defaultText);
}
});
<input name="KeywordBox" class="BasicSearchInputBox" type="text" size="300" value="Enter Keywords (address,city and state OR zipcode)"/>
如何不获取默认文本而仅获取用户输入?在jQuery中?