dom

querySelectorAll in Jquery

限于喜欢 提交于 2021-02-05 11:48:49
问题 Like the title how can I use DOM querySelectorAll() by jQuery. I am using final version of jQuery and Chrome browser For example: <ul> <li>new</li> <li>howler monkey</li> <li>pine marten</li> </ul> I tried $("li") but it just return the first li tag. -P/S: I have the answer to resolve this issue. I download jquery.js from jquery.com and linked to it but it just return the first li tag. $("li") <li>​new​</li>​ Then I used cdn link, it returns array result for me. I don't know why. $("li") (3)

SVG types support in Flow.js?

别来无恙 提交于 2021-02-05 10:42:06
问题 I've looked around at various github threads and it seems as if SVG support is not merged / shipped in current versions of Flow.js (I'm using VS Code extension vscode-flow-ide ). I'm trying to work with SVG refs and for now have had to use a mix of less-specific type ( Element ) and // $FlowFixMe to work around these - not ideal from a broader type-safety perspective. Anyone solved this? I'm using /flow/lib/dom.js currently, but it lacks these types. 回答1: Interrim solution until the official

Faster way to select an element with a given id

泄露秘密 提交于 2021-02-05 07:49:46
问题 I have a question. Let's say we have the following html tag: <div id='foo'>I am a div</div> Τhis div exists on the dom(it is not generated by javascript) If I want to use this div in javascript many times which is the better way to do it? store it in a variable like this: var d = $("#foo") or call it every time with jquery?: $("#foo").methodName() Which method does involve less dom traversal? 回答1: The fastest way is: document.getElementById("foo"); Setting this to a variable for reuse will

Extract data from HTML table row column

不打扰是莪最后的温柔 提交于 2021-02-05 07:47:26
问题 How to extract data from HTML table in PHP. The data is in this format Table 1 <tr><td class="body" valign="top"><a href="example"><b>DATA</b></a></td><td class="body" valign="top">Data_Text</td></tr> Table 2 <tr><th><div id="Data">Data</div></th><td>Data_Text_1</td><td>Data_Text_2</td></tr> Table 3 <tr><td width="120"><a href="example" target="_blank">DATA</a></td><td>Data_Text</td></tr> I want to get the Data & Data_Text or (Data_Text_1 & Data_Text_2) from the 3 tables . I've used $html =

CSS select first child if it's a certain tag

隐身守侯 提交于 2021-02-05 06:12:08
问题 I need to select a particular element only if it occurs as the first child of a div. Is there a CSS selector that'll handle that case? For example, I want to select this figure: <div> <figure></figure> <p></p> <p></p> </div> But I don't want to select this one: <div> <p></p> <figure></figure> <p></p> </div> I can't change the HTML, so I can't add a class. I know about the :first-child and :first-of-type selectors, but they don't fit this case by themselves. How can I select the first child

PHP DOM How to remove wrapping tags when children contain tags and text nodes

会有一股神秘感。 提交于 2021-02-05 05:59:25
问题 Given this markup <badtag> This is the title and <em>really</em> needs help <badtag> I need to remove the wrapper, but do it without losing the tag, which is what happens if I simply do something like: dom->createTextNode(currentNode->nodeValue) I've tried the following, but it's not quite working and I want to make sure I'm on the right track and not missing an easier way. I do note that I need to add iteration when I hit a tag in the switch statement (rather than #text) so that I get the

Find elements in a Node without the proper namespace, in Java

≡放荡痞女 提交于 2021-02-04 16:50:27
问题 So I have a xml doc that I've declared here: DocumentBuilder dBuilder = dbFactory_.newDocumentBuilder(); StringReader reader = new StringReader(s); InputSource inputSource = new InputSource(reader); doc_ = dBuilder.parse(inputSource); Then I have a function where I pass in a string and I want to match that to an element in my xml: void foo(String str) { NodeList nodelist = doc_.getDocumentElement().getElementsByTagName(str); } The problem is when the str comes in it doesn't have any sort of

Difference between object.src and object.getAttribute('src')

♀尐吖头ヾ 提交于 2021-02-04 16:17:06
问题 So, here is an example HTML code: <img src="test.png" id="test"> And here is a Javascript code: element = document.getElementById('test'); alert(element.getAttribute('src')); --> test.png alert(element.src); --> domain.com/test.png Why would getAttribute not show the domain, while .src yes, it adds the domain? Where can I find the difference between the different ways of accessing attributes in a DOM object? 回答1: You can see the difference in the HTML specification as “permitted attributes”

howto modify a webservice request using CXF interceptors with org.w3c.dom.Node

女生的网名这么多〃 提交于 2021-02-04 15:53:35
问题 Using a CXF Interceptor I'd like to append some Node to the xml being sent out to the server. I've created a interceptor (see below) that picks up the message as DOM Node, modifies it and writes it back to the message object. Unfortunately the code does not work as expected - the XML sent to the server does not contain the 'magicWord'. IMHO I'm using the wrong phase for this. So the question is: how can I modify an outgoing webservice request using the org.w3c.dom.Node syntax? package dummy;

How to read text that is under #shadow-root (user-agent)

牧云@^-^@ 提交于 2021-02-02 09:53:08
问题 I am using Selenium (Python) for automating a web page. I am trying to get text from an input field that is under #shadow-root (user-agent). Xpath I used: driver.find_element_by_xpath("**//*/p-calendar/span/input**").text is not returning anything. Attached the screenshot of my DOM element. Requirement: To get text from the shadow root : 01:01 回答1: As per @hayatoito 's (creator of Shadow DOM) comment: The original motivation of introducing a closed shadow tree is "Never allow an access to a