$(function(){
$(".sem").click(function(){
$(".comments").hide();
$(this).parent().next(".comments").show();
$(".circle.active").removeClass("active");
$(this).parent().addClass("active");
});
});
这是jQuery的代码,我想改用angular的话,这个要怎么写呀?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在你要加样式的元素上加 ng-class="{'active':classShowed}",classShowed是控制样式是否显示的变量。在controller中有$scope.classShowed bool型变量与之对应。在点击事件中控制$scope.classShowed的值(true,false)就能显示和隐藏样式了。详细自己百度 angular ng-class。