Select element by part of attribute contained in it

2

I have an element, for example:

<div class="teste" data-info="isflaolatesteum"></div>

And to select it, you could do it as follows:

$(".teste[data-info='isflaolatesteum']")...

However, I want to select this element through the attribute (data-info), but I only have part of the string contained in the attribute. As in the example above, I would like to select all elements that contain teste in the middle of the attribute, ie it would be like an indexOf in the attribute.

Is this possible?

    
asked by anonymous 04.11.2015 / 23:59

1 answer

2

You can use the jQuery contains selector for this.
*= in the attribute selector that is to say "containing the text".

In your case it would be

$(".teste[data-info*='teste']")

Example: link

    
05.11.2015 / 00:03