Pergunta

I need to check title attribute of a control with multiple values. Means title of control may be any of some 3 values.

For example :

alert($("table span[title='Excel']").text());

here title could be PDF or CSV too.

So how could we check title of span with multiple values using one selector.

for example:

$("table span[title='Excel'] || [title='2ndValue'] || [title='3rdValue']")
Foi útil?

Solução

You can use , to separate your selector:

$("table span[title='Excel'], table span[title='2ndValue'], table span[title='3rdValue']");

Fiddle Demo

Outras dicas

Try using .filter() in your context,

var title == "";

$("table span[title]").filter(function(){
 title = $(this).attr('title');
 return title === "title1" || title === "title2" || title === "title3";
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top