搜索框问题 点击前效果点击后效果,如何实现,请说的具体点javascript 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 方法很多常用1.placeholder,不支持的可以用js来模拟2. label , 根据input内容来判断label隐藏与否 <input type="text" value="大金空调" df="大金空调" onfocus="if(this.value==this.getAttribute('df'))this.value='';" onblur="if(this.value=='')this.value=this.getAttribute('df');"/> <input type"text" id="txtSearch" /> <script type="text/javascript"> String.prototype.trim =function(){ return this.replace(/^\s+|\s+$/g, ""); }; var txtSearch = document.getElementById("txtSearch"); var orgValue = "大金空调", isInput = false, value = ""; txtSearch.value = orgValue; txtSearch.onfocus = function () { if (!isInput) { value = txtSearch.value.trim(); if (txtSearch.value == orgValue) { txtSearch.value = ""; } } } txtSearch.onblur = function () { if (txtSearch.value.trim().length == 0) { txtSearch.value = orgValue; isInput = false; } else { isInput = true; } } </script> <style type="text/css">input{color:#C0C0C0}</style><script src="http://code.jquery.com/jquery-latest.js"></script><script type="text/javascript"> $(function(){ $("#abv").bind("focus",function(){ $(this).val(""); }); $("#abv").bind("blur",function(){ if($.trim($(this).val())==""){ $(this).val("大金空调"); } }); }) </script> <input id="abv" value="大金空调" type="text" /> js前端图表可以动态增长吗,并可以控制速度 求助 JQUERY根据是否有文本 决定CSS样式 js掉用web服务 拒绝访问 请问img有没有empty属性? 如何取得字串中某串字符的存在个数? 怎样实现在文本框输入所要的内容,在列表框中动态查找。 HTML 的 select 框的双击事件怎么做? 有关javascript和XML的问题 斑竹在吗?请帮忙看一下 大家看看自己的注册信息是不是给改了.csdn怎么回事了!!! bootstrap的模态框问题 有没有大神帮忙看看~ Ext border布局west中添加的树在最下边显示,求高手指点 网页关闭监听不起作用,望高手指教啊!!
常用
1.placeholder,不支持的可以用js来模拟
2. label , 根据input内容来判断label隐藏与否
<input type"text" id="txtSearch" />
<script type="text/javascript">
String.prototype.trim =function(){
return this.replace(/^\s+|\s+$/g, "");
}; var txtSearch = document.getElementById("txtSearch");
var orgValue = "大金空调",
isInput = false,
value = "";
txtSearch.value = orgValue;
txtSearch.onfocus = function () {
if (!isInput) {
value = txtSearch.value.trim();
if (txtSearch.value == orgValue) {
txtSearch.value = "";
}
}
}
txtSearch.onblur = function () {
if (txtSearch.value.trim().length == 0) {
txtSearch.value = orgValue;
isInput = false;
} else {
isInput = true;
}
}
</script>
<style type="text/css">
input{
color:#C0C0C0
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(function(){
$("#abv").bind("focus",function(){
$(this).val("");
});
$("#abv").bind("blur",function(){
if($.trim($(this).val())==""){
$(this).val("大金空调");
}
});
})
</script>
<input id="abv" value="大金空调" type="text" />