dom

Random characters in CSS class names

被刻印的时光 ゝ 提交于 2021-02-18 12:22:10
问题 I have noticed one thing. On some sites such as tray.io, asana, fb etc They have random characters in css class names when you inspect them for example: <header class="Header_XSDsdksdXKkSDD">..</Header> Why are these characters generated and how are they generated? Thanks. 回答1: Those class names or identifiers are probably generated by the engine that produces the page output. If you want to add a style to a particular element, you want a unique class for it - the easiest way is to generate

How do I Iterate over an XML in Java, with tags, that have the same name

守給你的承諾、 提交于 2021-02-17 06:10:26
问题 I'm trying to iterate over this xml-file in Java using the DOM-Library(have to use it), and so far I've been able to get certain elements just by directly asking for it this way: NodeList pList = document.getElementsByTagName("position"); Node pNode = pList.item(0); Element pElement = (Element) pNode; double xp = Double.parseDouble(pElement.getAttribute("x")); double yp = Double.parseDouble(pElement.getAttribute("y")); double zp = Double.parseDouble(pElement.getAttribute("z")); but this doesn

Javascript: getElementById vs getElementsById (both works on different pages)

╄→гoц情女王★ 提交于 2021-02-17 05:58:07
问题 I'm struggling with a really weird problem... I have two pages (quite the sames) where I need to disable some selects. On one of them (say page A), I use getElementById to retrieve my element, and on the second one (say page B) I use getElement s ById (with a 's') to retrieve it (and it works on both cases). What is weird is that if I use getElement s ById on page A (with the 's'), it gives me the error "document.getElementsById is not a function", which is normal because this function (with

Reference script container element?

五迷三道 提交于 2021-02-17 02:08:29
问题 I'm wondering if there is a way to get a handle on the DOM element that contains the script inside it. So if I had: <script type="text/javascript> var x = ?; </script> Is there a way that I can assign "x" a reference to the script element that contains "x"? 回答1: You could include some marker text in the script element, and then (similar to what David said), you can loop through all the script elements in the DOM (using getElementsByTagName or whatever features your library, if you're using

Reference script container element?

别来无恙 提交于 2021-02-17 02:08:07
问题 I'm wondering if there is a way to get a handle on the DOM element that contains the script inside it. So if I had: <script type="text/javascript> var x = ?; </script> Is there a way that I can assign "x" a reference to the script element that contains "x"? 回答1: You could include some marker text in the script element, and then (similar to what David said), you can loop through all the script elements in the DOM (using getElementsByTagName or whatever features your library, if you're using

how i can select element with double class with querySelector()

笑着哭i 提交于 2021-02-16 22:55:28
问题 i'm having problem when i want to select element using querySelector <ul class="xoxo blogroll"> </ul> how i can select that ul element, in my code i'm use like this var list = document.body.querySelector('ul[class="oxo blogroll"]'); alert(list.innerHTML); but the return is null ,i'm sure element ul with class xoxo blogroll is defined... thanks for your answer.. 回答1: document.body.querySelector("ul.xoxo.blogroll") And that is it... 回答2: Try this: document.body.querySelector('ul.xoxo.blogroll')

Why use document.getElementById when I can directly refer to the DOM id in JavaScript? [duplicate]

自古美人都是妖i 提交于 2021-02-15 11:39:04
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: IE/Chrome: are DOM tree elements global variables here? I recently discovered that I can use in javascript any object from DOM with a direct reference to its id: <div id="layer">IM A LAYER</div> <script> alert(layer.innerHTML); </script> If this is true, what advantage I'd get using the getElementById method? 回答1: Accessing a DOM element directly will give you a error if the element does not exist. Wheras if you

Why use document.getElementById when I can directly refer to the DOM id in JavaScript? [duplicate]

做~自己de王妃 提交于 2021-02-15 11:36:05
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: IE/Chrome: are DOM tree elements global variables here? I recently discovered that I can use in javascript any object from DOM with a direct reference to its id: <div id="layer">IM A LAYER</div> <script> alert(layer.innerHTML); </script> If this is true, what advantage I'd get using the getElementById method? 回答1: Accessing a DOM element directly will give you a error if the element does not exist. Wheras if you

Efficient way to read large XML into dfferent node types in C#

浪尽此生 提交于 2021-02-15 07:53:27
问题 I am new to C#. I have a relatively large XML file (28MB) and am trying to parse its subtrees into several different types based on their content. Essentially, I have 6900+ Content nodes that all have to be interrogated to figure out what type they are. <Collections> <Content>..</Content> <Content>..</Content> <Content>..</Content> ... </Collections> For each Content node, the variety of nodes below it can have 1 of 3 different patterns. I have to look into the node to decide which pattern

Console.log not working when testing regex

风流意气都作罢 提交于 2021-02-11 16:45:18
问题 Can someone explain why my console log is not working? Every time I select the file for verification to see if anything shows in the console nothing happens document.addEventListener("DOMContentLoaded", function() { document.getElementById('file').onchange = function() { var extPermitidas = ['txt']; var extArquivo = this.value.split('.').pop(); if (typeof extPermitidas.find(function(ext) { return extArquivo == ext; }) == 'undefined') { alert('The file cannot be used because its extension is