需要准备的材料分别有:电脑、html编辑器、浏览器。
1、首先,打开html编辑器,新建html文件,例如:index.html,编写问题基础代码。
2、在index.html中的<script>标签,输入js代码:$('div').click(function(){$(this).css('color','blue')})。
3、浏览器运行index.html页面,此时点击123所在的div,div会变为蓝色文本。
var domObj = document.getElementById("tagId")//使用domObj.style来设置css:
domObj.style.backgroundColor="#000"//对应style里 background-color
domObj.style.fontSize="#000"//对应style里 font-size
//如果对这个表不太清楚可以在w3c上查一下
//但是一般有个规律就是,首单词小写 “-”后面的第一个字母大写,如:font-size 就是fontSize
如果是想更换标签的class的话,可以使用
domObj.className = "other_class"