jquery判断input值不为空 val()

<input type="text" class="searchbox" />
<script type='text/javascript'>
$(document).ready(function(){
 //enter回车键激活搜索
    $('.searchbox').bind('keypress', function(event) {
        if (event.keyCode == "13")
        {
            search_news();
        }
    });
var k = $(".searchbox").val();
    if(k!=''){
    document.location = "/plus/search.php?kwtype=0&searchtype=title&q=" + encodeURI(k);
    }
</script>

 

posted @ 2016-12-02 09:47  幸福的目标  阅读(519)  评论(0编辑  收藏  举报