下面代码是一个搜索框代码,
我想实现如下功能
1。默认在搜索框里显示 “Enter product”, 这时CSS CLASS 为srch-query-boxNew
2。 输入关键字后, 搜索框显示关键字 ,这时CSS CLASS 为srch-query-boxNew_hightlight
3。 用户正在输入关键字时, 这时CSS CLASS 为srch-query-boxNew_hightlight
<div id="searchbox">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:11px;">
<tr>
<td width="13%" align="left"><strong style="font-size:15px;">Search</strong></td>
<td width="46%"><input type="text" value="Enter product" onfocus="onSearchFocus(this);"
onblur="onSearchBlur(this)" onmouseout="changeClass(this)" onmousemove="changeClass(this)" class="srch-query-boxNew"/></td>
<td width="6%" align="center"><input name="" type="radio" value="" checked="checked" /></td>
<td width="12%" align="left"> Product Keywords</td>
<td width="6%" align="center"><input name="" type="radio" value="" /></td>
<td width="10%" align="left">Product Number</td>
<td width="7%"><img src="images/icon_search.gif" /></td>
</tr>
</table>
</div><style>
<!--
.srch-query-boxNew {
border:1px solid #ccc; width:96%; padding:3px; font-size:10px; color:#999;
}
.srch-query-boxNew_hightlight {
border:1px solid #427DC7; width:96%; padding:3px; font-size:10px; color:#000;
}
-->
</style><script type="text/javascript"> function onSearchFocus(obj) {
if(obj.value=='Enter product') {
obj.value=''
}
} function onSearchBlur(obj) { if(obj.value =='') {
obj.value='Enter product';
changeClass(obj);
}
} function changeClass(q){
(q.className=="srch-query-boxNew")?q.className="srch-query-boxNew_hightlight":q.className="srch-query-boxNew";
}
</script>
我想实现如下功能
1。默认在搜索框里显示 “Enter product”, 这时CSS CLASS 为srch-query-boxNew
2。 输入关键字后, 搜索框显示关键字 ,这时CSS CLASS 为srch-query-boxNew_hightlight
3。 用户正在输入关键字时, 这时CSS CLASS 为srch-query-boxNew_hightlight
<div id="searchbox">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:11px;">
<tr>
<td width="13%" align="left"><strong style="font-size:15px;">Search</strong></td>
<td width="46%"><input type="text" value="Enter product" onfocus="onSearchFocus(this);"
onblur="onSearchBlur(this)" onmouseout="changeClass(this)" onmousemove="changeClass(this)" class="srch-query-boxNew"/></td>
<td width="6%" align="center"><input name="" type="radio" value="" checked="checked" /></td>
<td width="12%" align="left"> Product Keywords</td>
<td width="6%" align="center"><input name="" type="radio" value="" /></td>
<td width="10%" align="left">Product Number</td>
<td width="7%"><img src="images/icon_search.gif" /></td>
</tr>
</table>
</div><style>
<!--
.srch-query-boxNew {
border:1px solid #ccc; width:96%; padding:3px; font-size:10px; color:#999;
}
.srch-query-boxNew_hightlight {
border:1px solid #427DC7; width:96%; padding:3px; font-size:10px; color:#000;
}
-->
</style><script type="text/javascript"> function onSearchFocus(obj) {
if(obj.value=='Enter product') {
obj.value=''
}
} function onSearchBlur(obj) { if(obj.value =='') {
obj.value='Enter product';
changeClass(obj);
}
} function changeClass(q){
(q.className=="srch-query-boxNew")?q.className="srch-query-boxNew_hightlight":q.className="srch-query-boxNew";
}
</script>
解决方案 »
- (正则)js 正则判断输入的内容是否包含中文
- 这个验证错误在哪里?
- readplayer人工选择播放音乐问题
- 紧急求助大家关于用Javascript计算日期的问题,谢谢
- ie下正常运行,firefox下提示有错误
- 重新启动问题,wsh实现(再发。。。。。)
- 网页设计问题,我的网页是口字型。请进来看看!谢谢。
- 哪位知道这个onclick里的参数是啥意思啊?<INPUT TYPE="button" NAME="btn_Next" VALUE="继续" onClick="validateForm('products:productI
- 怎样实现点击一个文件链接即下载该文件的功能?
- 求一函数?给网页添加音乐
- Extjs分页问题,独自研究了四五天,实在没办法了
- js读取数据库
if (obj.value == 'Enter product') {
obj.value = ''
}
} function onSearchBlur(obj) { if (obj.value == '') {
obj.value = 'Enter product';
}
changeClass(obj);
} function changeClass(q) {
if (q.value != 'Enter product') {
q.className = "srch-query-boxNew_hightlight";
} else {
q.className = "srch-query-boxNew";
}
}
html:<div id="searchbox">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="font-size:11px;">
<tr>
<td width="13%" align="left"><strong style="font-size:15px;">Search</strong></td>
<td width="46%"><input type="text" value="Enter product" onfocus="onSearchFocus(this);"
onblur="onSearchBlur(this)" class="srch-query-boxNew"/></td>
<td width="6%" align="center"><input name="" type="radio" value="" checked="checked" /></td>
<td width="12%" align="left"> Product Keywords</td>
<td width="6%" align="center"><input name="" type="radio" value="" /></td>
<td width="10%" align="left">Product Number</td>
<td width="7%"><img src="images/icon_search.gif" /></td>
</tr>
</table>
</div>