QuerySelectorAll doesn't work as expected on img alt


Kennedy

This is the line of code I'm trying to target:<img class="pi" src="/graphics/ni/ni90.jpg" alt="Awaiting image">

I am trying to select all images with that propertyalt="Awaiting image"

if i trydocument.querySelectorAll("img.pi");

I will get all images with that classpi

if i trydocument.querySelectorAll("img.pi[alt="Awaiting image"]");

I get the error:Uncaught SyntaxError: missing ) after argument list

What am I missing here?

Quentin

The "value used to delimit the attribute selector is in conflict with the "literal used to delimit JS strings.

 document.querySelectorAll("img.pi[alt="Awaiting image"]");
                           ^           ^^
                           |           |Error
                           |           End of string
                           Start of string

Use different types of quotes.

 document.querySelectorAll('img.pi[alt="Awaiting image"]');

Related


HTML img, alt="" doesn't work

Fabio Reims I have another question. I use some icons on my website, in general, most people who play this game know these icons, but I don't think these icons are what I can give them using html alt="" tools, like tooltips Same. I do have them set as the firs

HTML img, alt="" doesn't work

Fabio Reims I have another question. I use some icons on my website, in general, most people who play this game know these icons, but I don't think these icons are what I can give them using html alt="" tools, like tooltips Same. I do have them set as the firs

querySelectorAll doesn't work?

I stock up on tea Here is my javascript code: function answer(){ var list = document.querySelectorAll("#fish"); list[1].onclick = talk(); } function talk(){ alert('hello!'); } window.onload = answer(); When running, it pops up a browser window with a warnin

querySelectorAll doesn't work

username I have a requirement where I have .divto pick the last container in the container and apply some business logic to it. The selection of the last option .divmust be dynamic, as the user can choose to add/remove .divelements. I tried it initially, query

img alt attribute doesn't seem to work in Google chorme

Juan Perez I have a problem with the below line of HTML code <img src="smile.gif" alt="Smiley face" width="42" height="42"> If the smile.gif image doesn't exist on the server, Google Chorme doesn't show the alt attribute like Firefox, instead it shows an empt

img alt attribute doesn't seem to work in Google chorme

Juan Perez I have a problem with the below line of HTML code <img src="smile.gif" alt="Smiley face" width="42" height="42"> If the smile.gif image doesn't exist on the server, Google Chorme doesn't show the alt attribute like Firefox, instead it shows an empt

:not() doesn't work as expected

username div.entry-content:not(body.single div.entry-content) { font-family: 'Droid Sans', sans-serif; margin-top:10px; line-height: 114%; font-size:15px; } The above css doesn't affect any elements at all....I want elements that exist inside

:not() doesn't work as expected

username div.entry-content:not(body.single div.entry-content) { font-family: 'Droid Sans', sans-serif; margin-top:10px; line-height: 114%; font-size:15px; } The above css doesn't affect any elements at all....I want elements that exist inside

:not() doesn't work as expected

username div.entry-content:not(body.single div.entry-content) { font-family: 'Droid Sans', sans-serif; margin-top:10px; line-height: 114%; font-size:15px; } The above css doesn't affect any elements at all....I want elements that exist inside

document.querySelectorAll ":not" with condition doesn't work

wsddd_ I tried to replace jQuery 's functionality .not()natively , but unfortunately it document.querySelectorAlldoesn't work for my use case. This is what I want to achieve - change the jQuery selector to vanilla JS: $('#someID').not('.classNameOne > div, .cl

querySelectorAll.style doesn't work

computer backup I'm writing something in JavaScript that I need to use, querySelectorAll.stylebut it always returns undefined, but works perfectly with querySelector.style. How can I make it work so I can style it? document.querySelector("div#tabs" + tabId + "

QuerySelectorAll(input[type=select]) doesn't work

Kirby L. Wallace I can select all other types of elements on the page except: var elems = querySelectorAll("input[type=select]"); Once I have them, I .disabledapply in a loop: for (var i = 0; i < elems.length; i++) { elems[i].disabled = true; } This appl

document.querySelectorAll ":not" with condition doesn't work

wsddd_ I tried to replace jQuery 's functionality .not()natively , but unfortunately it document.querySelectorAlldoesn't work for my use case. This is what I want to achieve - change the jQuery selector to vanilla JS: $('#someID').not('.classNameOne > div, .cl

QuerySelectorAll(input[type=select]) doesn't work

Kirby L. Wallace I can select all other types of elements on the page except: var elems = querySelectorAll("input[type=select]"); Once I have them, I .disabledapply in a loop: for (var i = 0; i < elems.length; i++) { elems[i].disabled = true; } This appl

querySelectorAll doesn't work in IE8?

test I'm talking about this is the ie8 related gallery : http://tympanus.net/codrops/2014/03/21/google-grid-gallery/ This is the line where js breaks: var x = this.grid.querySelectorAll( 'li:not(.grid-sizer)' ); But I think the problem started early. When I t

querySelectorAll.style doesn't work

computer backup I'm writing something in JavaScript that I need to use, querySelectorAll.stylebut it always returns undefined, but works perfectly with querySelector.style. How can I make it work so I can style it? document.querySelector("div#tabs" + tabId + "

querySelectorAll.style doesn't work

computer backup I'm writing something in JavaScript that I need to use, querySelectorAll.stylebut it always returns undefined, but works perfectly with querySelector.style. How can I make it work so I can style it? document.querySelector("div#tabs" + tabId + "

CSS *:not(img) doesn't work

Peter Anson I've searched various sources and all are saying the same thing. this code: *:not(img) { display: none; } Everything except the image should be hidden. But it also hides the image. What's wrong? Accompany Affi As found in the comments, this will m

CTRL+ALT+T doesn't work

lead I'm using Ubuntu 12.04 and the shortcut was working fine until the day before yesterday. But when I pressed it today, it didn't open the terminal. Terminal applications still work. I'm using GNOME3 3.4.2, recentlyapt-get install gnome-shell The keyboard s

CTRL+ALT+T doesn't work

lead I'm using Ubuntu 12.04 and the shortcut was working fine until the day before yesterday. But when I pressed it today, it didn't open the terminal. Terminal applications still work. I'm using GNOME3 3.4.2, recentlyapt-get install gnome-shell The keyboard s

CTRL+ALT+T doesn't work

lead I'm using Ubuntu 12.04 and the shortcut was working fine until the day before yesterday. But when I pressed it today, it didn't open the terminal. Terminal applications still work. I'm using GNOME3 3.4.2, recentlyapt-get install gnome-shell The keyboard s

whenAll() doesn't work as expected

Murali Uppangala I need to make the UI thread wait for the task array to finish executing. The problem with the following code is - the task in turn calls the UI thread to write to the textbox. how to solve this problem? public partial class FormConsole : Form

sum() doesn't work as expected

tdm I have a query that can query the monthly income of an individual. I want to get the sum of their different incomes (2 jobs, pensions, etc). Since they are monthly values, I also need to multiply by 12 to get their total annual income select DISTINCT f.mon

sendmsg() doesn't work as expected

fenixan I wrote a program with a simple client and server pair, the first generates a bunch of strings and sends them through the API provided by sockets, i.e. sendmsg(), the second receives the strings by facilitating epoll. Based on what tcpdump captures and

Wget doesn't work as expected

Συλχαν wget -nd -a pdf -o drgnchain.pdf https://dragonchain.com/assets/Dragonchain_Business_Summary.pdf I want the downloaded PDF to be named and unique drgnchain.pdfafter executing this command . However, not only does this command accidentally get 2 files,

SetRootPath doesn't work as expected

Jacob I have used part of the code (PyQt5) from this post from PyQt5.QtWidgets import QTreeView,QFileSystemModel,QApplication class Main(QTreeView): def __init__(self): QTreeView.__init__(self) model = QFileSystemModel() model.setR

replace() doesn't work as expected

ziiweb Why is " name " not replaced here? var foo = '<div> <label class="required">_1_label__</label><div id="project_frontendbundle_car_1___name__"><div> <label for="project_frontendbundle_car_carImages___name___position" class="

removeDuplicates doesn't work as expected

Geeks I'm trying to extend the Array prototype with the following function: Array.prototype.uniqueItems=function(){ var ar=this,unique=[],max=ar.length; for(var i = 0 ; i < max;i++) if(unique.indexOf(ar[i] )==-1) unique.push(ar[i]);

replace() doesn't work as expected

ziiweb Why is " name " not replaced here? var foo = '<div> <label class="required">_1_label__</label><div id="project_frontendbundle_car_1___name__"><div> <label for="project_frontendbundle_car_carImages___name___position" class="