Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 452
Clem Avatar asked Dec 03 '22 01:12

Clem


2 Answers

$("span:contains('role=\"alert\"')")
like image 85
Rajat Singhal Avatar answered Jan 05 '23 13:01

Rajat Singhal


You can simply use:

​$('span[role="alert"]')​​​​​​​​​​​​​​​​​​​.each(function() {        
    alert($(this).text());
});
like image 32
Zathrus Writer Avatar answered Jan 05 '23 13:01

Zathrus Writer