如何在jQuery中选择数据ID和数据操作 [英] how to select data-id and data-action in jQuery

查看:82
本文介绍了如何在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和数据操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆