How to access a jquery without id?

0

I always access a jquery using the command: $('#id_1') , but always in an html body that has id . How do I access an html body that does not have id , using the data-uid attribute in my case below?

<img data-uid="_b03bc8304532" ui-sref=".image({uidImage: 
&quot;_b03bc8304532&quot;})" width="450" height="450">
    
asked by anonymous 24.08.2018 / 20:08

2 answers

1

Try using the attribute selector: Stack Overflow Response

It would look something like: img[data-uid*="_b03bc8304532"]

You have more references on this link: Attribute Selector

    
24.08.2018 / 20:11
3

It may look like this:

$('*[data-uid="_b03bc8304532"]');

Select all elements with this data-uid . I changed to a span to demonstrate:

$('*[data-uid="_b03bc8304532"]').html('texto alterado');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><spandata-uid="_b03bc8304532"></span>
    
24.08.2018 / 20:27