function y()
{
var a = document.all || document.getElementsByTagName("*");
for(i=0;i<a.length;i++)a[i].style.color = 'red';
}
{
var a = document.all || document.getElementsByTagName("*");
for(i=0;i<a.length;i++)a[i].style.color = 'red';
}
解决方案 »
- 即时显示消息
- window.showModalDialog和window.open
- jquery的deferred疑问
- 关于图片拖动的问题
- javascript实现多语言碰到的问题
- javascript 如何实现隔1分钟就 document.all.Button1.click(); 一次?
- 父页面的select有一组值,有办法接受弹出窗口传过来的值改变selected吗?
- 怎样给按钮加上说明文字?
- 请问: style['mvBoundary'], currentStyle['mv--grid']是什么意思呀?请高手指点一下!。
- JS随机调用外部CSS来实现刷新网页自动换风格,该如何写呢?
- 客户端设置cookie和服务器端设置cookie有何不同
- 验证radio是否被选中
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
document.body.innerHTML=document.body.innerHTML.replace(/(祝大家中秋节快乐!!!)/g,"<span style='color:red'>$1</span>")
}
</script>
</body>
function y()
{var o=document.body;
o.innerHTML=o.innerHTML.replace(/(祝大家中秋节快乐!!!)/g,"<span style='color:red'>$1</span>")
}霍霍~~没玩过Mozilla,让老大们见效
祝两位老大中秋快乐
笨了!发现老大给Body加了id……
<body id="x" onclick="y()">
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{x.innerHTML=x.innerHTML.replace(/(祝大家中秋节快乐!!!)/g,"<span style='color:red'>$1</span>")
}
</script>
</body>ps:楼上的见效改为见笑……
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
var a = document.all || document.getElementsByTagName("*");
for(i=0;i<a.length;i++)a[i].style.color = 'red';
}</script>
</body>
{
document.body.style.color = "red";
}
勉强可以
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
var netLove = document.all;
for(i=0;i<netLove.length;i++)
{
netLove[i].style.color = "red"
}
}
</script>
</body>
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
document.body.style.color='red';
}
</script>
</body>
难道
<body id="x" onclick="y()">
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
x.style.color='red';
}
</script>
</body>
……………………
不知道Mozilla行不行
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
x.text = "red";
}
</script>
</body>
看来是我的最短啦~~~
<a id=a1>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
//在这里写代码,实现目标:在页面上点击鼠标,把页面上的所有文字的颜色变成红色,
for (var i=0;i<document.all.length;i++)
{
document.all(i).style.color = 'red';
}
}
</script>
</body>
<a>祝老大和大家中秋节快乐!!!</a>
<div>祝老大和大家中秋节快乐!!!</div>
<p>祝老大和大家中秋节快乐!!!</p>
<h3>祝老大和大家中秋节快乐!!!</h3>
</body>
<script language="vbs">
sub y()
for each netLove in document.all
netLove.style.color = "red"
next
end sub
</script>
</body>
<body id="x" onclick="y()">
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
<style></style>
<script language="javascript">
function y()
{
document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
}
</script>
</body>
<body id="x" onclick="y()">
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
<style></style>
<script language="javascript">
function y()
{
document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
}
</script>
</body>
document.body.text='red'
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
</body>
<script>
function y()
{
document.fgColor = "red";
//在这里写代码,实现目标:在页面上点击鼠标,把页面上的所有文字的颜色变成红色,
}
</script>
</body>
<p style="color: green">祝大家中秋节快乐!!!</p>对于这些已经定义过字体颜色的对象, 通过定义BODY的fgColor, style.color 等等方法都是无用的!
<div style="color: blue">祝大家中秋节快乐!!!</div>
<p style="color: green">祝大家中秋节快乐!!!</p>对于这些已经定义过字体颜色的对象, 通过定义BODY的fgColor, style.color 等等方法都是无用的!
--------------------------------------------------------------------------- 嘿嘿,我们是应试教育的产物~~~只看题,不考虑创新~~~~ ^_^
我觉得这道题最简单的做来是用样式表解决, 而不应该用循环定义每个element
<body id="x" onclick="y()">
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
<style></style>
<script language="javascript">
function y()
{
document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
}
</script>
</body>
回复人: meizz(梅花雪 1+1=3) ( ) 信誉:694 2004-09-28 14:56:00 得分: 0
我觉得这道题最简单的做来是用样式表解决, 而不应该用循环定义每个element
<body id="x" onclick="y()">
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
<style></style>
<script language="javascript">
function y()
{
document.styleSheets[0].addRule("*", "color: red"); //就一句代码就够了
}
</script>
</body>
___________________________________________________________________________严重同意!可惜回家的班车上才想到:(
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3>
<style></style>
<script language="javascript">
function y()
{
var o = document.getElementById("x");
o.style.color='red';
}
</script>
</body>
1,mikespook(懒猫开始新生活) 是比较好的答案,也是我当初的想法,虽然text在html3.2标准中就已经存在了,但后来已经不推荐使用了,但浏览器仍然都支持的,但是,你的解答在Mozilla里没有效果,应该严格dom的方法进行操作。应该写成document.getElementById("x").text='red'
2,现在最简捷也最正确的应该是 bencalie(Bencalie) 的了。因此可以得到150分的高分,其它分数属于小礼物
不行,要去找个Mozilla装一下~~~这样下去岂不完蛋~~~
<body id="x" onclick="y()"><span style="color: blue">
<a>祝大家中秋节快乐!!!</a>
<div>祝大家中秋节快乐!!!</div>
<p>祝大家中秋节快乐!!!</p>
<h3>祝大家中秋节快乐!!!</h3></span>
</body>
<script>
function y()
{
document.fgColor = "red";
}
</script>这样设置fgColor就已经完全失效了. 所以我认为还是fason的代码最好!! :)
{
var a = document.all || document.getElementsByTagName("*");
for(i=0;i<a.length;i++)a[i].style.color = 'red';
}
这个简单,拿来支持
{
var a = document.all || document.getElementsByTagName("*");
for(i=0;i<a.length;i++)a[i].style.color = 'red';
}
--------------
fason的这个好~支持。
document.color='red'
}