Jquery确定搜索关键字是否为空,并确定搜索请求跳转实现代码片段
以下代码为项目开发片段,实现方法仅供参考。
//搜索
$(‘#submit-search’).on(‘click’, function () {
var $keyWorld = $(“.header-search .txt”).val();
$keyWorld = $.trim($keyWorld);
var identify = $(‘#search-identify’).val();
if ($keyWorld.length <= 0) {
alert(‘请输入搜索关键词 …’);
return false;
}
window.location.href = ‘//ithov.com/search/video?keyWorld=’ + $keyWorld + ‘&identify=’ + identify;
});
$(“.header-search .txt”).keydown(function (event) {
if (event.keyCode === 13) { //绑定回车
$(‘#submit-search’).click();
}
});
文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/115077.html<