dom

Console.log not working when testing regex

风格不统一 提交于 2021-02-11 16:41:29
问题 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

Console.log not working when testing regex

随声附和 提交于 2021-02-11 16:41:02
问题 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

Fast alternatives for `element.clientHeight` and `element.offsetHeight`

别来无恙 提交于 2021-02-11 14:23:39
问题 I need the element.clientHeight and element.offsetHeight of an HTMLElement, but calculating it is very slow, and especially, it takes for about 3 seconds my long element that we can scroll on! Is there a fast alternative to these two? getBoundingClientRect() does not work and it has the same performance. Similar question: text editor in textarea SLOW - javascript It seems for the elements doesn't automatically grow, this calculation is very slow. 来源: https://stackoverflow.com/questions

Manipulate the DOM using jQuery, without changing the react code

泪湿孤枕 提交于 2021-02-11 12:33:52
问题 Let's say I want to develop a third party plugin, like a chrome extension. So I will have absolutely no privilege to change the javascript code of the page. All I can do is add things external to the page. So I would use jQuery to manipulate the DOM. But if the page is rendered by react, what I did to the DOM would be erased in the react lifecycle. I see some tutorials teaching how to integrate jQuery in to a react app. But this is not what I need. Is there any way to manipulate the DOM

How to use getElementsByClassName() for adding both grids and display one after another?

♀尐吖头ヾ 提交于 2021-02-11 12:13:22
问题 I Have Tried to add grid-2 when we press a key, but it's not working as I expected. When it is displaying grid-2 I want the grid to disappear (I don't know how to do). (background):- I have searched and found there is a visibility property in CSS, but don't know how to apply to the whole grid and undo the visibility property and make them visible. I have tried to add the grid-2 by getElementById but both the grids are appearing at a time. (don't know how to make them appear one after another)

using getElementByID in React

允我心安 提交于 2021-02-11 07:12:27
问题 I am getting a "Cannot read property 'style' of null" on my getElementById('password'), but its clearly defined on the page. I'm new to react, and I'm guessing this isn't allowed or something. But I'm trying to have the password page show until, its style is changed to "none", which happens in a different component. function App() { const [loggedIn, setLoggedIn] = useState(false) if (document.getElementById('password').style.display = "block"){ setLoggedIn(false) } else { setLoggedIn(true) }

using getElementByID in React

无人久伴 提交于 2021-02-11 07:11:57
问题 I am getting a "Cannot read property 'style' of null" on my getElementById('password'), but its clearly defined on the page. I'm new to react, and I'm guessing this isn't allowed or something. But I'm trying to have the password page show until, its style is changed to "none", which happens in a different component. function App() { const [loggedIn, setLoggedIn] = useState(false) if (document.getElementById('password').style.display = "block"){ setLoggedIn(false) } else { setLoggedIn(true) }

JavaScript in React to modify the DOM

做~自己de王妃 提交于 2021-02-11 06:54:36
问题 I have a component with a div.modal that I would like to transition with CSS. The initial values are set for w=0 and h=0 , transition is all, 1s . This component is a conditional render wihin another component named - <Starter /> , which in turn is a component of <Home /> . I have tried this in a number of places however the DOM is not ready { document.getElementsByClassName('modal').style.width = 'auto' } The component: const JoinSign = () => { return ( <div id="overlay"> <div className=

VueJS - DOMException: “The operation is insecure.”

百般思念 提交于 2021-02-10 23:42:02
问题 I am getting DOMException: "The operation is insecure." error in the console from my website (using Vue). It only happens when it's hosted on github pages but it it doesn't error when it's being run locally. Github page url: https://cubxity.github.io/ks/#/display/2227?scopes=&displayTime=true My browser is Firefox, build id: 20181206201918 回答1: TL;DR: This isn't a Vue issue: you cannot programmatically alter the contents of a form input through the DOM. Input file fields are more rigorously

VueJS - DOMException: “The operation is insecure.”

做~自己de王妃 提交于 2021-02-10 23:41:04
问题 I am getting DOMException: "The operation is insecure." error in the console from my website (using Vue). It only happens when it's hosted on github pages but it it doesn't error when it's being run locally. Github page url: https://cubxity.github.io/ks/#/display/2227?scopes=&displayTime=true My browser is Firefox, build id: 20181206201918 回答1: TL;DR: This isn't a Vue issue: you cannot programmatically alter the contents of a form input through the DOM. Input file fields are more rigorously