FAQ Database Discussion Community


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 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...

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...

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 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...

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...

How to select the