js属性有哪些 js写入HTML js对事件可以做出反应 js改变HTML的内容 js能改变HTML的图像

document.write() 显示

onclick是指单击事件

alert()是指弹出框 <button type="button" onclick="alert('WELCOME')">点击这里</button>

getElementById("demo") //查找id是demo的元素

innerHTML双向功能 1.获取对象的内容,2.向对象中插入内容

<html>  <body>   <p id="demo">     JavaScript 能改变HTML的内容   </p>

  <script>         function Myfunction(){              x=document.getElementById("demo");//找到元素              x.innerHTML="HELLO WORLD";//改变内容             }   <\script>    <button   type="button" onclick="Myfunction()">点击这里<\button>  <\body> <html>

点击图像使灯亮和灯灭 <html> <body>  <script>    function changImage(){      element=document.getElementById('myimage');     if(element.src.match("bulbon")){          element.src="/i/eg_bulboff.git";          }       else{             element.src="/i/eg_bulbon.gif";          }  <\script>     <img id="myimage" onclick="changImage()" src="/i/eg_bulboff.gif">

<\body>

 

<\html>

 

posted on 2018-10-24 14:10  illusory_f  阅读(97)  评论(0编辑  收藏  举报