/* 搜索文本框效果 */ $(function(){ $("#inputSearch").focus(function(){ $(this).addClass("focus"); if($(this).val()==this.defaultValue){ $(this).val(""); } }).blur(function(){ $(this).removeClass("focus"); if($(this).val()==""){ $(this).val(this.defaultValue); } }).keyup(function(e){ if(e.which==13){ alert("回车提交表单!"); } }) })
注意:在写input搜索文本框样式时,行距中最好用padding值来控制,因为用line-height在IE有兼容性问题。
转载于:https://blog.51cto.com/lflianglan/1205614