函数没有为我的简单按钮show-div javascript定义

时间:2017-02-28 16:54:42

标签: javascript jquery html

对此有何看法?当用户按下按钮时,最初隐藏的div必须在页面上显示。

<!DOCTYPE html>
    <html>
    <head>

    <style>
        div {
        display: none;
        }
    </style>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
        function show() {
                $("div").toggle();
        }
    </script>

    </head>


    <body>
    <p>Animals are cute!</p>
    <div><p>Some text gonna blow up some pixels!</p></div>
    <button onclick="show()">Click</button>

    </body>

    </html>

控制台中确切写入的错误:

ReferenceError: show is not defined[Learn More

2 个答案:

答案 0 :(得分:3)

将内联脚本移动到自己的标记中。您无法在同一标记中使用外部脚本和内联脚本。

所以:

 struct aba {
      void *ptr;
      uint32_t tag;
 };

答案 1 :(得分:0)

&#13;
&#13;
 public void playSound(View view, ??? sound){
        mpSound = MediaPlayer.create(this, R.raw.sound);
        mpSound.start();
    }
&#13;
function show() {
    $(".any-text").toggle();
}
&#13;
.any-text {
    display: none;
}
&#13;
&#13;
&#13;