【发布时间】:2015-08-19 20:25:18
【问题描述】:
我已经创建了一个 jQuery 悬停函数:
$('.deleteButton').hover(function(){
$(this).css('opacity', '1');
},
function(){
$(this).css('opacity', '.5');
});
当我将 HTML 元素硬编码到 index.html 文档中时,它起作用了,但当我从模板导入元素时不起作用。
下面的模板:
<div class="logBox">
<div class="dateAndLocation">
<p>{{ info.date | date }}</p>
<p style="margin-top:-.7em">{{ info.location }}</p>
</div>
<div class="routeNameBox">
<p class="routeName">{{ info.routeName }}</p>
<p class="gradeAndType">{{ info.grade }} | {{ info.type }}</p>
</div>
<div class="timeAndLevelBox">
<div class="timeBox pull-left">
<p class="timeText">{{ info.time }}</p>
</div>
<div class="pclBox pull-right">
<p class="pclText">{{ info.challengeLevel }}</p>
</div>
</div>
<div class="notesBox">
<p class="notesText">{{ info.notes }}</p>
</div>
<div class="photoCircle" style="background-image:url({{ info.photo }})"></div>
</div>
<div class="deleteButton"><p>—</p></div>
index.html 代码:
<div class="container" style="min-width:1200px; margin:auto;" ng-repeat="climbLog in climbLogs">
<climb-log info="climbLog"></climb-log>
<div>
它工作正常并按预期重复.. 但是当我将鼠标悬停在删除按钮上时,它不会改变它的不透明度,正如 jQuery 函数中指定的那样(在我开始使用模板之前已经工作)
【问题讨论】:
-
不要将 jQuery 与 Angular 一起使用,不推荐使用它会导致很多问题。可能这个链接会给你一些帮助docs.angularjs.org/api/ng/directive/ngMouseover
-
jQuery 能与 Angular 相比吗?我只是想知道我是否应该尝试兼顾两者的知识,或者只是完全投资于 Angular。我认为 jQuery 适合静态网站,而 Angular 适合动态网站/webapps……你同意吗?
-
深入了解Angular之后可以使用jquery。
-
你可以这么说(jQuery 适合静态网站,而 Angular 适合动态网站)。即便如此,这只是因为 angular 很“重”并且可以做很多事情,并且将其包含在一个简单的静态站点中将是一种浪费。但不要像这样在同一个网站中混合使用它们。
标签: javascript jquery html css angularjs