<table border="1" cellspacing="0" width="400" cellpadding="0" id="table1">
<tr>
<td width="80"><input type="text" value="12"></td>
<td width="80"><input type="text" value="324"></td>
<td width="80"><input type="text" value="56"></td>
<td width="80"><input type="text" value="78"></td>
<td width="80"><input type="text" value="90"></td>
</tr>
<tr>
<td width="80"><input type="text" value="abc"></td>
<td width="80"><input type="text" value="def"></td>
<td width="80"><input type="text" value="ghj"></td>
<td width="80"><input type="text" value="lop"></td>
<td width="80"><input type="text" value="dry"></td>
</tr>
<tr>
<td width="80"><input type="text" value="!@#"></td>
<td width="80"><input type="text" value="_(*"></td>
<td width="80"><input type="text" value="#$%"></td>
<td width="80"><input type="text" value="^$#"></td>
<td width="80"><input type="text" value="WWW"></td>
</tr>
</table><SCRIPT>
var ids;
var idstext;
function hightlight_td(){
var text=txt.value;
TDs=document.all.table1.all.tags("TD")
//使用iframe时:
//TDs=iframe的name.document.all.table1.all.tags("TD")
if (text!="")
{
for (var i = 0; i < TDs.length; i++)
{
obj=TDs[i].childNodes[0];
idstext=obj.value;
idnum=idstext.indexOf(text);
if (idnum!=-1)
{
obj.style.background="red";
}
else
{
obj.style.background="#FFFFFF";
}
}
}
else
{
alert("没有输入");
}
}
</SCRIPT>
<p align="center"><input type="text" name="txt" value=""><input type="button" value="请输入要查的字符串." onClick="hightlight_td();"></p>
<tr>
<td width="80"><input type="text" value="12"></td>
<td width="80"><input type="text" value="324"></td>
<td width="80"><input type="text" value="56"></td>
<td width="80"><input type="text" value="78"></td>
<td width="80"><input type="text" value="90"></td>
</tr>
<tr>
<td width="80"><input type="text" value="abc"></td>
<td width="80"><input type="text" value="def"></td>
<td width="80"><input type="text" value="ghj"></td>
<td width="80"><input type="text" value="lop"></td>
<td width="80"><input type="text" value="dry"></td>
</tr>
<tr>
<td width="80"><input type="text" value="!@#"></td>
<td width="80"><input type="text" value="_(*"></td>
<td width="80"><input type="text" value="#$%"></td>
<td width="80"><input type="text" value="^$#"></td>
<td width="80"><input type="text" value="WWW"></td>
</tr>
</table><SCRIPT>
var ids;
var idstext;
function hightlight_td(){
var text=txt.value;
TDs=document.all.table1.all.tags("TD")
//使用iframe时:
//TDs=iframe的name.document.all.table1.all.tags("TD")
if (text!="")
{
for (var i = 0; i < TDs.length; i++)
{
obj=TDs[i].childNodes[0];
idstext=obj.value;
idnum=idstext.indexOf(text);
if (idnum!=-1)
{
obj.style.background="red";
}
else
{
obj.style.background="#FFFFFF";
}
}
}
else
{
alert("没有输入");
}
}
</SCRIPT>
<p align="center"><input type="text" name="txt" value=""><input type="button" value="请输入要查的字符串." onClick="hightlight_td();"></p>
解决方案 »
- 不修改IE安全性,使用new ActiveXObject("WScript.Shell")如何不弹出提示?
- 在javascript中以ie浏览器打开链接
- 求助!怎样用JS控制一个表格的字体。而其他字体并不改变?
- 如何实现JS中fullscreen,但有工具栏?
- 高分求教:怎样实现表单内容的检测?
- 用JAVASCRIPT怎样来实现对鼠标左右键的控制!
- 使用document.execCommand('SaveAs')时能不能不弹出保存对话框????
- 关于粘贴的问题
- javascript在脚本中动态插入图片前如何放缩一下图片
- angularjs在微信内置浏览器中的兼容性问题
- 提问:如何动态屏蔽表格中的某一列,有没有简单的办法?
- 高手来,help,谢谢。
<table border="1" cellspacing="0" width="400" cellpadding="0" id="table1">
<tr>
<td width="80"><input type="text" value="12"></td>
<td width="80"><input type="text" value="324"></td>
<td width="80"><input type="text" value="56"></td>
<td width="80"><input type="text" value="78"></td>
<td width="80"><input type="text" value="90"></td>
</tr>
<tr>
<td width="80"><input type="text" value="abc"></td>
<td width="80"><input type="text" value="def"></td>
<td width="80"><input type="text" value="ghj"></td>
<td width="80"><input type="text" value="lop"></td>
<td width="80"><input type="text" value="dry"></td>
</tr>
<tr>
<td width="80"><input type="text" value="!@#"></td>
<td width="80"><input type="text" value="_(*"></td>
<td width="80"><input type="text" value="#$%"></td>
<td width="80"><input type="text" value="^$#"></td>
<td width="80"><input type="text" value="WWW"></td>
</tr>
</table><SCRIPT>
var ids;
var idstext;
function hightlight_td(){
var text=txt.value;
TDs=document.all.table1.all.tags("TD")
//使用iframe时:
//TDs=iframe的name.document.all.table1.all.tags("TD")
if (text!="")
{
for (var i = 0; i < TDs.length; i++)
{
obj=TDs[i];
idstext=obj.childNodes[0].value;
idnum=idstext.indexOf(text);
if (idnum!=-1)
{
obj.childNodes[0].style.background="red";
}
else
{
obj.childNodes[0].style.background="#FFFFFF";
}
}
}
else
{
alert("没有输入");
}
}
</SCRIPT>
<p align="center"><input type="text" name="txt" value=""><input type="button" value="请输入要查的字符串." onClick="hightlight_td();"></p>
<tr>
<td width="80"><input type="text" value="12"></td>
<td width="80"><input type="text" value="324"></td>
<td width="80"><input type="text" value="56"></td>
<td width="80"><input type="text" value="78"></td>
<td width="80"><input type="text" value="90"></td>
</tr>
<tr>
<td width="80"><input type="text" value="abc"></td>
<td width="80"><input type="text" value="def"></td>
<td width="80"><input type="text" value="ghj"></td>
<td width="80"><input type="text" value="lop"></td>
<td width="80"><input type="text" value="dry"></td>
</tr>
<tr>
<td width="80"><input type="text" value="!@#"></td>
<td width="80"><input type="text" value="_(*"></td>
<td width="80"><input type="text" value="#$%"></td>
<td width="80"><input type="text" value="^$#"></td>
<td width="80"><input type="text" value="WWW"></td>
</tr>
</table><SCRIPT>
function find_txt(){
text=document.getElementById("txt").value;
if(text==""){
alert("没有输入");
return;
}
tds=document.getElementById("table1").getElementsByTagName("input");
for(var i=0;i<tds.length;i++){
findt=tds[i].value.indexOf(text);
if(findt!=-1){
tds[i].style.backgroundColor="#ff0000";
}else{
tds[i].style.backgroundColor="#ffffff";
}
}
}
</SCRIPT>
<p align="center"><input type="text" name="txt" id="txt" value=""><input type="button" value="请输入要查的字符串." onClick="find_txt();"></p>