如何在jQuery中选择数据ID和数据操作

编程入门 行业动态 更新时间:2024-10-28 06:30:53
本文介绍了如何在jQuery中选择数据ID和数据操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是此问题的后续措施:使用javascript:function语法和jQuery选择器进行Ajax调用

This is a follow-up to this question: Using javascript:function syntax versus jQuery selector to make Ajax calls

我将如何选择此片段?

<div data-id="54" data-action="follow-global-id" class="add-to-list">here is my answer</div>

我在下面有id值,并尝试过

I have the id value below and tried this

$('.add-to-list[data-action|="action-follow-global-id"][data-id|=id]').text('here is the things jtjt in the id value');

但没有骰子.需要将这些AND在一起.

but no dice. Need to be AND'ing these together.

寻求帮助

推荐答案

未测试,但应该可以工作:

Didn't test it, but should work:

var id = 54; $('.add-to-list[data-action=follow-global-id][data-id='+id+']').text('something');

更多推荐

如何在jQuery中选择数据ID和数据操作

本文发布于:2023-10-19 11:21:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507340.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   操作   如何在   jQuery   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!