repeat我不能運行href =#所以我無法運行javascript函數。 a.click將打開toogle文字,或a.click將關閉toogle文字。Angular ng-repeat a href =#and toogle not working
的JavaScript:
<script>
$(".toggle-container").hide();
$(".trigger").toggle(function(){
$(this).addClass("active");
}, function() {
$(this).removeClass("active");
});
$(".trigger").click(function(){
$(this).next(".toggle-container").slideToggle();
});
$(".trigger.opened").toggle(function(){
$(this).removeClass("active");
}, function() {
$(this).addClass("active");
});
$(".trigger.opened").addClass("active").next(".toggle-container").show();
的toogle格:
<div class="toggle-wrap" ng-repeat="question in questions">
<span class="trigger opened"><a href="#"><i class="toggle-icon"></i>{{question.title}}</a></span>
<div class="toggle-container" >
<p>{{question.text}}</p>
</div>
</div>
喲。這是AngularJS應用中的很多jQuery。請閱讀此:http://stackoverflow.com/questions/14994391/thinking-in-angularjs-if-i-have-a-jquery-background – isherwood
另外,Jscript!= JavaScript。請勿隨意縮寫。 – isherwood