一、总结
<form class="navbar-form navbar-left" role="search"> <div class="form-group"> <input type="text" data-url="{{url('/search_lesson')}}" class="form-control" id="navbar-search-input" placeholder="找课程"> </div> </form> {{--找课程回车键事件--}} <script> $(function () { //$("#focus")为获取id为focus的元素 $("#navbar-search-input").keypress(function(event){ if(event.which === 13) { //点击回车要执行的事件 let search_content=$('#navbar-search-input').val(); let url=$('#navbar-search-input').data('url'); url=url+'/'+trim(search_content); window.location.href=url; //console.log(search_content); console.log(url); return false; } }) }); </script>
<form class="navbar-form navbar-left" role="search"> <div class="form-group"> <input type="text" data-url="{{url('/search_lesson')}}" class="form-control" id="navbar-search-input" placeholder="找课程"> </div> </form> {{--找课程回车键事件--}} <script> $(function () { //$("#focus")为获取id为focus的元素 $("#navbar-search-input").keypress(function(event){ if(event.which === 13) { //点击回车要执行的事件 let search_content=$('#navbar-search-input').val(); let url=$('#navbar-search-input').data('url'); url=url+'/'+trim(search_content); window.location.href=url; //console.log(search_content); console.log(url); return false; } }) }); </script>
二、内容在总结中
原文链接:https://www.cnblogs.com/Renyi-Fan/p/11870232.html
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/18172