分享我的第一个js事件效果

Original 2019-01-31 18:21:35 220
abstract:<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>Document</title>    <style>    .example{widt

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Document</title>

    <style>

    .example{width: 300px;height: 200px;border: 1px solid #ccc;background: lightcoral;color:#fff;text-align: center;line-height: 200px; }

    #hello{background: chartreuse;width: 300px;height: 200px;}

    

    </style>

</head>

<body>

  <div id="hello" onclick="two(this)"></div>

  <div></div>

  <div></div>

  <button onclick="myFunction()">点击</button>

  <script>

  function myFunction() {

      var x = document.getElementsByClassName("example");

      x[0].innerHTML = "花开花落花无悔!";

      x[1].innerHTML = "缘来缘去缘如水!";

  }

  function two(y){

  var li =document.getElementById("hello");

  li.style="background:red;width:500px;height:500px;border-radius: 50%;";

  }

  </script>

  

</body>

</html>


Correcting teacher:韦小宝Correction time:2019-02-01 09:45:28
Teacher's summary:写的很不错 这种就是要多练习才可以熟练的掌握 继续加油吧!

Release Notes

Popular Entries