Clem
Clem

Reputation: 69

Double quotes in Jquery

I have read several posts regarding usinq quotes in jQuery and have not been able to form my own query. I have to check a span tag for a particular string. The string i am searching for is: role="alert" (it has double quotes around the word alert.

$("span:contains('role="alert"')").each(function() {        
        alert($(this).text());
    });

Can someone provide a query for this?

Upvotes: 4

Views: 6231

Answers (2)

Zathrus Writer
Zathrus Writer

Reputation: 4331

You can simply use:

​$('span[role="alert"]')​​​​​​​​​​​​​​​​​​​.each(function() {        
    alert($(this).text());
});

Upvotes: 4

Rajat Singhal
Rajat Singhal

Reputation: 11264

$("span:contains('role=\"alert\"')")

Upvotes: 13

Related Questions