<html>
<head>
<script type=“text/javascript” src="/home/js/jquery-3.1.1.min.js"></script>
</head>
<body>
<header class="ease2">
<div>
<button class="search-submit" id="search-button" onclick="searchPro()">搜索</button>
<input name="keyword" id="keyword" placeholder="请输入文本" value="" type="text">
</div>
</header>
<script type="text/javascript">
function searchPro(){
var keyword = $("#keyword").val();
window.location.href="/home/index/index?name="+keyword ;
}
</script>
</body>
</html>
在searchPro()函数中没有取到input输入框的value!没有重定向到指定的页面
请大家帮我看看!真搞不懂
Uncaught ReferenceError: $ is not defined 说明jquery框架导入错误
下面代码测试正常
<header class="ease2">
<div>
<button class="search-submit" id="search-button" onclick="searchPro()">搜索</button>
<input name="keyword" id="keyword" placeholder="请输入文本" value="" type="text">
</div>
</header>
<script src="https://g.csdnimg.cn/??lib/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
function searchPro() {
var keyword = $("#keyword").val();
alert(keyword)
window.location.href = "/home/index/index?name=" + keyword;
}
</script>
引入jq库了吗
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!input 的 value="" 去掉