News Articles DOM

How can i get DOM of specific page like ""?

for this problem I need to say I use fetch method but some web, like google and .. does not allow it. I want to get DOM of a page for tracking it, for example : I wanna check if an element change let me know. How can I get an specific web page DOM […]

Is there a library that provides useState and useEffect as an API for traditional web components?

I been building web components for a while now, and wondering how to implement use State and use Effect API provided in react. Write one myself. How can I implement use State and use Effect on vanilla web components? Source: CSS – Stack Overflow

HTML ID naming for similar text entry boxes

In a demo site I have four text boxes which are grouped into two pairs of two. I use only IDs and a naming scheme to get javascript to read each one individually. Is there a cleaner way of using element selectors to avoid having so many similarly named IDs and duplicated code? Example HTML […]

Avoiding many similar IDs for similar text entry boxes

In a demo site I have four text boxes which are grouped into two pairs of two. I use only IDs and a naming scheme to get javascript to read each one individually. Is there a cleaner way of using element selectors to avoid having so many similarly named IDs and duplicated code? Can CSS […]

Scroll to bottom of div after changing contents using Javascript

For some reason the methods to scroll to bottom of div are not working for me after refreshing its contents using Ajax. I think the issue has something to do with how the DOM works–eg when it makes its changes, however, I don’t know enough about javascript or the DOM to really understand how that […]

Make contents of div scroll after to bottom after replacing contents via Ajax using Javascript

I am replacing the contents of a div using Ajax. However after the new contents are retrieved from a server, I would like to scroll to the bottom. I tried calling the function to scroll to bottom after the function to reload the div but that did not work. I also tried placing the function […]

How does javascript update the elements in a DOM?

I am trying to slow down an animation of a picture shrinking so that you can actually see it shrink instead of just jump to a smaller size, but what instead happens is that my console log updates as it should-with intervals in-between each update, but the image on the screen waits until the for […]

Presenting Two New JavaScript Courses

We’re excited to announce the launch of two new courses, JavaScript and the DOM and Interacting with the DOM. Students will bring web pages to life using the power of JavaScript, one of the essential tools for creating fun, interactive,… The post Presenting Two New JavaScript Courses appeared first on Treehouse Blog. Source: Treehouse Blog

Selector choose wrong element

I have script that shows one element: var size = document.getElementsByName(‘length’); for (var i = 0 ; i < size.length; i++) { size[i].addEventListener(‘change’, function() { if (this.checked) { document.querySelector("#battery").style.display = ‘block’; } }); } And another script that choses another element: var sizeOld = document.getElementsByName(‘lengthOld’); for (var i = 0 ; i < sizeOld.length; i++) […]

DOM issues using jQuery .load() – how to load HTML file into main HTML template and execute jQuery/JS against loaded file? [duplicate]

I am having trouble with an HTML file (inc_1.html) I’m loading into my main template (index.html) using jQuery .load(). My getTotal function doesn’t execute the JS in Example #2 but it does execute in Example #1. I was wondering if anyone could see what the problem is and whether callback functions ( or Cross Origin […]

e.preventDefault() still sends me to another page

In this exercise I am supposed to make a grocery list by submiting a form, but when i press submit it sends me to another page even if I use e.preventDefault() const container = document.querySelector(‘#list’); form.addEventListener(‘submit’,function(e){ e.preventDefault(); const getProduct = form.elements.product.value; const getQty = form.elements.qty.value; const newli = document.createElement(‘li’); newli.append(getQty); newli.append(` ${getProduct}`); container.append(newli); form.elements.product.value = […]

How do I pass an event to sibling components in Svelte?

I have a table component, which has multiple table rows inside it created using #each. Each row has a variable(not a prop) representing which cell inside it is currently selected, this value is updated and stored in localStorage anytime a cell is clicked. I also have a special row at the very end of the […]

Event listeners firing multiple times

I have a menu that appears when a container element is clicked, this is done by changing the menu’s display property from ‘none’ to ‘inline’ so that when the menu is not in use it is removed from the dom. When the menu is generated, each of its child elements (in this case list items) […]

Why can’t I focus on an input element after calling alert in electron?

Whenever I call alert in electron, a message box shows up. After I close this message box, I cannot focus on an input element. After I switch to another window and back to the app, only then can I focus. I am working on windows and haven’t tested on other platforms. I am using electron […]

Why is this version of my code not working?

So i have a form that takes an input and then renders the input on the page in the form of list items. My current code loops through the array which contains the input values and assigns the list element with the input value to the Ul element i have as innerHTML. I tried using […]

Get "absolute" CSS transformation matrix

I am implementing a set of custom elements that will be used like this: <om-root> … <om-node id="node1"> … <om-node id="node2"> … </om-node> … </om-node> … <om-root> That is, my <om-node> elements will be mixed in with arbitrary HTML, which may have positioning and/or CSS transform applied. The purpose of these <om-node> elements is to […]

Adding a class using jQuery

Below script works if the URL correct and then create P tag and adds a Notice class to it. I’m working on a different page now, which does not have a ID to target, I tried by using getElementsByClassName but it didnt work. Does it always needs to be a ID? if(window.location.href.indexOf("/members/directory/index.xsp") > -1) { […]

Playwright Select frame with dynamic name

I need to access an iframe in playwright that has a name that is automatically generated. The iframe’s name is always prefixed by "__privateStripeFrame" and then a randomly generated number How i can access the frame with the page.frame({name: }) ? From the docs it seems like i can’t use a regular expression! Source: JavaSript […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.