FAQ Database Discussion Community


Array.prototype.splice.call - not working with a querySelectorAll('.className')

javascript,html,css,arrays,queryselectorall
I have three divs with a class name of .column , on the bottom, before my body tag I have a small script which is supposed to get these divs and put them into an array so that I can work on them. I've done this before so I don't...

How to get the div that has a duplicated id using querySelector()?

javascript,dom,queryselectorall
I have a <div> and a <video> that both have the same id: <div id="id1"> Some content </div> <video id="id1"> <source></source> </video> It is not possible for me to change the IDs of the div or the video. The div is created automatically by the video.js library, which gives both...

Element-relative CSS selectors

javascript,jquery,css-selectors,queryselectorall
Is there a way to shorten these types of lines by using CSS selectors and jQuery? $(element).parent('tr').parent('tbody').parent('table') $(element).children('tbody').children('tr').children('td') It is basically: "get me the direct parent/children if any" I need 100% equal selectors. UPDATE: closest('table) does not work: can return the element itself AND may find not direct parents find('td')...

JavaScript Accordion Menu with querySelectorAll()

javascript,toggle,accordion,custom-data-attribute,queryselectorall
I'm attempting to build an accordion menu using querySelectorAll() but unsure what the best method would be to check if the clicked list item's children (.toggleContent and .toggleIcon) belong to it's clicked parent toggle_li[i]. Correct me if I am wrong, but I assume that controlling this within the onclick function...

Is it possible to make querySelectorAll live like getElementsByTagName?

javascript,dom,css-selectors,getelementsbytagname,queryselectorall
getElementsByTagName() has 2 great features: it is fast and it is live. But what if I want to get p strong. Of course I could refine a selection using getElementsByTagName() again but wouldn't I loose the live effect for the new p tags? Is there a way to turn querySelectorAll...

Javascript querySelectorAll, how to match with only top elements?

javascript,jquery,html,polymer,queryselectorall
I am using polymer. Let say I have something in Template as follows <ul> <li> Home </li> <li> About </li> <li> Actions <ul> <li> Logout </li> </ul> </li> </ul> In Ready function var listNodes = this.querySelectorAll('ul > li'); I need help with this javascript query selector. The current query I...

Invalid selector with querySelectorAll :not with descendants

javascript,css-selectors,queryselectorall
I've got a case where I need to select different groups of nodes on a page, and I need to exclude certain child elements. My most common task is selecting all <img> elements, but not some that are descendants of certain elements. Take for example my fiddle here: http://jsfiddle.net/rjdbys13/ I...

for of loop querySelectorAll

javascript,google-chrome,for-loop,mozilla,queryselectorall
Mozilla states that "for of loops will loop over NodeList objects correctly". (source: https://developer.mozilla.org/en-US/docs/Web/API/NodeList) However, this doesn't work in Chrome 43. Is this incorrect documentation or a browser bug? The copied example code used on a page with checkboxes: var list = document.querySelectorAll( 'input[type=checkbox]' ); for (var item of list)...

How to select the