dom

Chrome extension: Insert fixed div as UI

≡放荡痞女 提交于 2020-12-29 03:45:50
问题 I want to insert a div into a fixed position using a chrome extension. It will overlay the page that you are currently viewing. My concern is that I want this to work on any page without altering it (other than inserting my fixed div), but I don't know if that is possible with the way that I'm doing it. Currently, the button won't show up, and I had a lot of trouble getting the div to show up. By the way, the positioning is just temp for now, I will position it correctly once I get it on the

How to get the new value of an HTML input after a keypress has modified it?

坚强是说给别人听的谎言 提交于 2020-12-28 10:42:21
问题 I have an HTML input box <input type="text" id="foo" value="bar"> I've attached a handler for the ' keyup ' event, but if I retrieve the current value of the input box during the event handler, I get the value as it was, and not as it will be! I've tried picking up ' keypress ' and ' change ' events, same problem. I'm sure this is simple to solve, but at present I think the only solution is for me to use a short timeout to trigger some code a few milliseconds in the future! Is there anyway to

Why does removing an element with javascript prevent iteration of elements?

丶灬走出姿态 提交于 2020-12-26 08:25:33
问题 I am trying to replace all text fields on a page with labels. function replaceInputTextFieldsWithValues() { var inputFields = document.getElementsByTagName("input"); for(var i = 0; i < inputFields.length; i++) { if(inputFields[i].getAttribute("type")== "text") { var parent = inputFields[i].parentNode; var value = inputFields[i].value; parent.removeChild(inputFields[i]); var label = document.createElement('label'); label.setAttribute('for', value); label.innerHTML = value; parent.appendChild

How to execute document.querySelectorAll on a text string without inserting it into DOM

拜拜、爱过 提交于 2020-12-24 15:22:31
问题 var html = '<p>sup</p>' I want to run document.querySelectorAll('p') on that text without inserting it into the dom. In jQuery you can do $(html).find('p') If it's not possible, what's the cleanest way to to do a temporary insert making sure it doesn't interfere with anything. then only query that element. then remove it. (I'm doing ajax requests and trying to parse the returned html) 回答1: With IE 10 and above, you can use the DOM Parser object to parse DOM directly from HTML. var parser =

How to execute document.querySelectorAll on a text string without inserting it into DOM

拜拜、爱过 提交于 2020-12-24 15:21:12
问题 var html = '<p>sup</p>' I want to run document.querySelectorAll('p') on that text without inserting it into the dom. In jQuery you can do $(html).find('p') If it's not possible, what's the cleanest way to to do a temporary insert making sure it doesn't interfere with anything. then only query that element. then remove it. (I'm doing ajax requests and trying to parse the returned html) 回答1: With IE 10 and above, you can use the DOM Parser object to parse DOM directly from HTML. var parser =

why js closest method not find sibling element?

对着背影说爱祢 提交于 2020-12-15 00:44:58
问题 Note: as far as i know that closest() method searches up the DOM tree for the closest element which matches a specified CSS selector. When i click on margin space between two li element .. it's return null... but if i replace margin-bottom: 15px; with padding-bottom ... everything is okay... CSS Code .amenities-filters-inner ul li{ margin-bottom: 15px; } Image if i click on red mark area.. it's not found sibling li element .. Example Code document.querySelectorAll(".amenities-filters-inner ")

why nextelementsibling return null | dom traversing js

这一生的挚爱 提交于 2020-12-13 03:11:02
问题 when I click on title ( Title Goes Here) text. I am getting null for nextElementSibling instead of a element... Edit you can nest any elements inside an <a> except the following : <a> <button> follow link <a> and <button> both are invalid.. but I am getting null for a tag.. not for button tag.... I am looking for more clarity and valid source... if I console log console.log(document.links) .. it's give three HTMLCollection collection... End Edit Below Example Code console.log(document.links)

why nextelementsibling return null | dom traversing js

ぃ、小莉子 提交于 2020-12-13 03:10:30
问题 when I click on title ( Title Goes Here) text. I am getting null for nextElementSibling instead of a element... Edit you can nest any elements inside an <a> except the following : <a> <button> follow link <a> and <button> both are invalid.. but I am getting null for a tag.. not for button tag.... I am looking for more clarity and valid source... if I console log console.log(document.links) .. it's give three HTMLCollection collection... End Edit Below Example Code console.log(document.links)

why nextelementsibling return null | dom traversing js

こ雲淡風輕ζ 提交于 2020-12-13 03:10:15
问题 when I click on title ( Title Goes Here) text. I am getting null for nextElementSibling instead of a element... Edit you can nest any elements inside an <a> except the following : <a> <button> follow link <a> and <button> both are invalid.. but I am getting null for a tag.. not for button tag.... I am looking for more clarity and valid source... if I console log console.log(document.links) .. it's give three HTMLCollection collection... End Edit Below Example Code console.log(document.links)

Scroll to a particular div using id in reactJs without using any other library

我的未来我决定 提交于 2020-12-10 06:29:25
问题 Scroll to a particular div using id in react without using any other library, I found a few solutions they were using scroll libraries here's the div code in my WrappedQuestionFormFinal component <div className="form-section"> <Row> <Col xs={24} xl={4} className="form-section-cols"> <h3 id={id}> {t('QUESTION')} {t(id + 1)} </h3> </Col> </Row> </div> it's a nested component called through this component here <WrappedQuestionFormFinal allQuestions={questions} updateScreenTitle={this.props