(function(){ //事件绑定 //导航栏悬浮触发二级导航栏,首页和院士列表不需要触发 $('.header_navBar > li:not(:nth-child(1))').on('mouseenter',(e)=>{ $(e.currentTarget).find('.header_tri').show(); $(e.currentTarget).find('.header_subNav').css({'display':'flex'}); $('.header_sub_bg').show(); }); $('.header_navBar > li:not(:nth-child(1))').on('mouseleave',(e)=>{ $(e.currentTarget).find('.header_tri').hide(); $(e.currentTarget).find('.header_subNav').hide(); $('.header_sub_bg').hide(); }); let url = "/ysgList/index.html?keywords="; //搜索按钮点击提交表单 $('.header_searchIcon').on('click',function(){ let inputVal = $('.header_input').val().trim(); window.location.href = url + inputVal; }); //搜索框添加回车提交表单事件 $('.header_input').keyup(function(e){ if(e.keyCode == 13){ //当且仅当搜索框不为空的时候才执行回车提交 let inputVal = $('.header_input').val().trim(); if(inputVal.length > 0){ $('.header_input').val(inputVal); window.location.href = url + inputVal; } } }); })();