dom

How do I remove selected text from an input control?

爷,独闯天下 提交于 2021-01-27 23:31:27
问题 Basically, I want to be able to detect: if there is highlighted text inside of a text input How to remove the selected text I set up a fiddle to show how far I got, but I can't figure out how to remove the given text. http://jsfiddle.net/z36Px/ Here is my markup <input type='text' value='Hello World!' id='txtbox' /> <br /> <button id="btnSelect">select text</button> <button id="btnRemove">remove selected text</button> and my javascript $("#btnSelect").click(function () { document

Execute A Function When All xmlHttpRequests Are Complete

时间秒杀一切 提交于 2021-01-27 19:09:17
问题 BRIEF I have a website which gets data from an API. So it makes some post and get requests to a server once the website is opened. Let us assume it makes 5 different xmlHttpRequests as soon as the page loads but we cannot exactly know the time each call takes from start to finish. FOR EXAMPLE Call to one endpoint takes 2 seconds to complete and the other one takes 1 second to complete. So that means after 2 seconds both the calls are said to be finished . TO-DO I want to execute a function

Can you load a web page in c++, including JS and dynamic html and get the rendered DOM string?

别说谁变了你拦得住时间么 提交于 2021-01-27 18:49:17
问题 Is it possible to load a web page in c++ and get the rendered DOM? Not just the HTTP response, but the rendered DOM that occurs after java-script runs (maybe after letting it run for some amount of time). Specifically the dynamic HTML that may have changed over time? Is there a library for this? Or if not c++, do you know of any other language which this can be done in? Edit here's an example to illustrate better why one might want to do this: Imagine you want to crawl a website written in

How can I change the color of a particular element of a HTMLDocument in a JEditorPane?

心不动则不痛 提交于 2021-01-27 18:39:42
问题 I basically want to implement changing the color of the links when I hover over them. The HyperlinkEvent that is triggered when I mouse over the link hands me the HTML element, but it won't let me set any style attributes on it, and I can't figure out how to get the elements that do have settable attributes. 回答1: I figured out what I wanted to do using styled documents and bit of help from the HTMLEditorKit: public class HighlightHyperlinkExample { private static Element

What exactly the purpose of React Virtual DOM

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-27 18:36:13
问题 While going through react I came up with the following doubts: DOM operations are very expensive But eventually react also does the DOM manipulation. We cannot generate a view with Virtual DOM. Collapsing the entire DOM and building it affects the user experience. I never did that, Mostly what I do is changing the required child node(Instead of collapsing entire parent) or appending HTML code generated by JS. Examples: As a user scrolls down we append posts to parent element, even react also

why does my checkbox always get unchecked?

泪湿孤枕 提交于 2021-01-27 17:43:01
问题 The following code adds a checkbox and a label to the calling node. My question lies in the label.click function. Whenever the label is clicked I want to change the state of the matching checkbox. What happens however is that the checkbox always ends up unchecked. For debugging purposes I now always explicitly set it to checked. When I step through the code with firebug I see that the checkbox gets checked and then, when leaving the function it gets unchecked again. Any ideas? jQuery.fn

Are DOM elements passed by reference to console.log? [duplicate]

别说谁变了你拦得住时间么 提交于 2021-01-27 14:11:21
问题 This question already has answers here : How can I make console.log show the current state of an object? (11 answers) Closed 6 years ago . I'm not even sure exactly what I'm asking here. I just know it isn't what I expected. I have a page script (see below) that grabs a reference to an element by its ID, then calls a few functions on it. Each function logs the element (or its textContent ) to the console, modifies the text contents, then calls the next function. What confuses me is how those

What is the purpose of textContent in an input element?

♀尐吖头ヾ 提交于 2021-01-27 12:20:51
问题 Provided an input element in a DOM, it does have a textContent property along with value . It is well known that the value of the input is what shown in the text box, and this element cannot have any children, that is <input>something</input> still gives an empty input followed by a sibling text node, whereas closing tag is completely ignored. But when we set a value to the textContent of this input, it is somehow survives the round-trip: input.textContent = 'something' console.log(input

What is the purpose of textContent in an input element?

时光总嘲笑我的痴心妄想 提交于 2021-01-27 12:15:13
问题 Provided an input element in a DOM, it does have a textContent property along with value . It is well known that the value of the input is what shown in the text box, and this element cannot have any children, that is <input>something</input> still gives an empty input followed by a sibling text node, whereas closing tag is completely ignored. But when we set a value to the textContent of this input, it is somehow survives the round-trip: input.textContent = 'something' console.log(input

What exactly updates when the DOM is manipulated

爷,独闯天下 提交于 2021-01-27 06:52:51
问题 I am trying to understand exactly what is updated with the regular DOM after a DOM manipulation. Suppose we have the DOM below and I use javascript to delete the li with the class blue. Does this mean that the browser looks at the parent of class blue (eg: id of list 1) and re-renders that DOM node including all the children (minus class blue) and then repaints the whole page based on any css rules? I would think that would be the process but I wasn't sure and can't find any concrete examples