我有以下代码。但是,当查看此静态页面时,我正在寻找的#id和.classes在部分内容时,我的JQuery不会运行。我如何让它工作?
<body ng-app>
<h2>JQuery wont run if code it is looking for is in a Partial</h2>
<div ng-include="'_includes/partials/menu.html'" ></div>
<br />
<h2>JQuery will work if the code it is looking for is here on the page (DOM)</h2>
<div class="container">
<div class="row">
<div class="col-xs-12">
<ul class="nav">
<li><a>Home</a></li>
<li><a>About</a></li>
<li><a>Services</a></li>
</ul>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="_includes/scripts/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"></script>
<script src="_includes/scripts/custom.js"></script>
</body>
答案 0 :(得分:0)
尝试在AngularJS应用程序中查找html元素并修改它们并不是一个好习惯,就像在启用JQuery的html中一样。相反,尝试使用Angular实现您正在考虑的任何内容。
答案 1 :(得分:0)
无论如何,你想使用ng-directives代替jQuery调用。