Double quotes in jQuery

I read several posts about usinq quotes in jQuery and could not form my own request. I have to check the span tag for a specific line. The line I'm looking for is: role = "alert" (it has double quotes around the warning by words.

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

Can someone provide a request for this?

+4
source share
2 answers
 $("span:contains('role=\"alert\"')") 
+13
source

You can simply use:

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

Source: https://habr.com/ru/post/1437249/


All Articles