技术部学习报告 (17.10.20)

2017-10-20  本文已影响0人  _paper

document.getElementById("名") - 通过ID获取元素

<body>
<p id="con"> I Love JavaScript </p>
<script type="text/javascript">
var mychar = document.getElementById("con");
document.write("结果" + mychar.innerHTML);
</script>
</body>


style(改变样式)

<script type="text/javascript">
var mychar = document.getElementById("con");
mychar.style.color = ”green";
</script>


display("none", "block")

<form>
<input type="button" onclick="hidetext()" value="隐藏文本">
<input type="button" onclick="showtext()" value="显示文本">
</form>
function hidetext()
{
var mychar = document.getElementById("con");
mychar.style.display="none";
}
function showtext()
{
var mychar = document.getElementById("con");
mychar.style.display="block";
}


上一篇 下一篇

猜你喜欢

热点阅读