- {{item}}
$scope.cityFinish = function() {
$('.city').css('background', 'red');
$('.city1').css('background', 'green');
};
其中 $('.city').css('background', 'red');有效,但是$('.city1').css('background', 'green');无效,这是什么原因?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你先审查一下元素。确保它的 class 是对的。
首先,不知道你的
repeat-done是如何写的。这应该不是 angularjs 自带的。其次,为什么不把颜色写到 css 中,然后用
ng-class或者ng-style处理,一定要用 jQuery 呢。你的需求是不是,除了 index 为 1 的背景色为绿色,其他的都为红色?
能不用 jQuery 就别用,更何况你还有内置的 jqLite 可以用。。。jQuery 作为第三方库,如果你不针对 angularjs 封装,那么你不能保证它的执行一定是在生成节点之后的,特别是对于 custom directive。