Skip to content
Advertisement

Tag: html

How can I use document.querySelector to select this class name with a space in it?

I have been using But now, the class name has changed: there’s a space and some new text in the class name: How can I change el = document.querySelector(“.PrmryBtnMed”); to find the right class? I tried using el = document.querySelector(“.PrmryBtnMed.ApricotWheat”); but that didn’t work. Next, I tried to add a space (and escape using a backslash): el = document.querySelector(“.PrmryBtnMed ApricotWheat”);

How can I run a jQuery function only when it’s needed?

I’ve run into a problem where I have a responsive slider running on my site which has been added to an external .js file. I am running into an issue with a modal not popping up on the homepage because the page is looking for the slider which is only included on a couple of sub pages. Chrome console is

Image swapping when a variable changes

I have an html page that has one image object. I am trying to write some JavaScript but something isn’t working in the script. I have a piece of script that reads a variable and if the variable ‘e’ is equal to 1, then one image appears. If ‘e’ is anything other number then image 2 appears. For now, ‘e’

Can’t get width property with JavaScript

My idea is when I click on the button, the div#x will lose 1% of width. Here is my code: The blue bar (div#x) is supposed to be shorter 1% every time I click on the left button (section#a). I have check so many times but I still don’t know what problem with my code. I did change some code

Cannot click input element within button element

Take a look at the below markup & fiddle: http://jsfiddle.net/minlare/oh1mg7j6/ In Chrome, each element within the button can be selected through the developer console and js click events are delegated. In Firefox/IE you cannot select the child elements or pickup js click events. Is there a way around this in Firefox/IE? Answer It is not suggested to use elements inside

Difference between document.hidden vs document.hasFocus()

Please explain the difference between document.hidden , the HTML5 Page Visibility API and document.hasFocus(). I am doing a project which pops HTML5 Desktop Notification when the tab is not focused. I am kind of confused which one to use. Answer The hidden attribute is defined like this: On getting, the hidden attribute MUST return true if the Document contained by

Advertisement