timpone timpone - 2 years ago 245
Javascript Question

how to select data-id and data-action in jQuery

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

How would I select this fragment?

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

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');

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

thx for help

Answer Source

Didn't test it, but should work:

var id = 54;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download