900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > html语言怎么改变字体颜色 JS实现改变HTML上文字颜色和内容的方法

html语言怎么改变字体颜色 JS实现改变HTML上文字颜色和内容的方法

时间:2018-06-27 16:52:24

相关推荐

html语言怎么改变字体颜色 JS实现改变HTML上文字颜色和内容的方法

本文实例讲述了JS实现改变HTML上文字颜色和内容的方法。分享给大家供大家参考,具体如下:

1. JavaScript

Day 1

// to change the color of an object.

function changeColor(){

x=document.getElementById("Id1");

x.style.color="Red";

}

// to change the content of an object.

function changeContent(){

y=document.getElementById("Id2");

y.innerHTML="Hi, you have changed the contents using Java Script successfully!";

}

Welcome Page

It is test 1.

It is test 2.

Change color of test 1

Change content of test 2

2. Day 1.html

Day 1

// to change the color of an object.

function changeColor(){

x=document.getElementById("Id1");

x.style.color="Red";

}

// to change the content of an object.

function changeContent(){

y=document.getElementById("Id2");

y.innerHTML="Hi, you have changed the contents using Java Script successfully!";

}

Welcome Page

It is test 1.

It is test 2.

Change color of test 1

Change content of test 2

3. 运行效果截图:

PS:这里再提供几款文字特效工具供大家参考:

希望本文所述对大家JavaScript程序设计有所帮助。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。