JQuery不工作;简单警报(“你好”); [重复]

时间:2022-12-01 16:50:25

This question already has an answer here:

这个问题在这里已有答案:

<script type="text/javascript" src="jquery-2.0.3.min.js">
    alert("hello");
</script>

I wrote an inline function that for some reason when I ran onclick says it doesn't exists so I tried to simplify it completely till it works but I found out even this code doesn't work. It does work on a empty page though!It is located under all my other code in said page; no body tags only DIVs - right after the last div .Maybe it is because of the frameworks I'm using? I have firebase/angularjs/nodejs. I also tried to do document ready calls and console.log(); getting no errors but also nothing popping up either. EDIT: it is literally not a duplicate because I tried all other solutions. Here is more code: I tried to put it into the last div and outside of it.

我写了一个内联函数,由于某种原因,当我运行onclick说它不存在所以我试图完全简化它直到它工作,但我发现即使这个代码不起作用。它确实在空白页面上工作!它位于所述页面中的所有其他代码之下;没有身体标签只有DIV - 就在最后一个div之后。也许是因为我正在使用的框架?我有firebase / angularjs / nodejs。我还尝试做文件就绪调用和console.log();没有错误,也没有任何突然出现。编辑:它实际上不是重复,因为我尝试了所有其他解决方案。这是更多的代码:我试图把它放在最后一个div和它之外。

<!-- <a class="btn-for-pw" ng-href="">Forgot Password?</a> -->

              </form><!-- end of #signupForm -->

          </div>

          <!--Footer-->
          <div class="modal-footer text-center">
              <a ng-href="#/register">Create an Account</a>
          </div>

      </div>
      <!--/Form with header-->

  </div>
  </div>
 <script type="text/javascript" src="jquery-2.0.3.min.js"/>
<script>
    alert("hello");
</script>

1 个解决方案

#1


0  

Try putting another script tag after you include your jQuery source. as the script inside will be disregarded.

在包含jQuery源代码后尝试添加另一个脚本标记。因为内部的脚本将被忽略。

Here is a jjsFiddle

这是一个jjsFiddle

<script type="text/javascript" src="jquery-2.0.3.min.js"/>
<script>
    alert("hello");
</script>

Good luck :-)

祝你好运 :-)

#1


0  

Try putting another script tag after you include your jQuery source. as the script inside will be disregarded.

在包含jQuery源代码后尝试添加另一个脚本标记。因为内部的脚本将被忽略。

Here is a jjsFiddle

这是一个jjsFiddle

<script type="text/javascript" src="jquery-2.0.3.min.js"/>
<script>
    alert("hello");
</script>

Good luck :-)

祝你好运 :-)