gpt4 book ai didi

javascript - 使用angularJS单击时更改目标属性

转载 作者:行者123 更新时间:2023-11-29 16:14:37 25 4
gpt4 key购买 nike

<ul class="todo-list">
<li ng-repeat="todo in todos">{{todo.todoContent}}<span class="pull-right glyphicon glyphicon-check" ng-class="{checked:todo.done}" ng-click="todoCheck(todo)" title="check this todo">check</span></li>
</ul>

现在,当我单击 span 元素以检查目标待办事项时,我想将标题属性更改为“取消选中此待办事项”并将文本“检查”更改为“已检查”。
任何人都可以在这里提供帮助。非常感谢。

example fiddle

最佳答案

如果你想对你点击的元素进行更细粒度的控制,你可以通过在 ng-click 处理程序中使用 $event 来实现。

喜欢

ng-click="todoCheck($event, todo)"

我已经使用 jquery 设置标题和内容并更新了你的 fiddle 。

Here is the updated fiddle

$scope.todoCheck = function ($event, todo) {

   var spanElement = $event.srcElement;

$(spanElement).attr('title', "uncheck this todo");

$(spanElement).html("checked");

todo.done = !todo.done;

};

关于javascript - 使用angularJS单击时更改目标属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18781520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com