Questions tagged [dom]

The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

Filter by
Sorted by
Tagged with
2 votes
1 answer
29 views

Unit test for a React click-counting component

Take this basic component using state: ...
user avatar
0 votes
0 answers
18 views

Home page with divs that appear when clicked

I imagine home page like two div(for example) user choose one of them and after he click now two new div appears and user do same process for example 5 times. In the HTML its just two times repeat div ...
user avatar
1 vote
1 answer
29 views

Refactored Todolist created using TS

After getting the code review I refactored the code and the updated version is below. I tried implementing the suggestions but because I am still learning I might refactor again after learning how to ...
user avatar
2 votes
1 answer
72 views

Animating GIF on hover in Javascript

I don't know JavaScript and it's safe to say this is my first code ever written in JS. I just needed to animate my GIFs when user hovers over them only. Googling separate concepts such as "string ...
user avatar
  • 1,375
2 votes
1 answer
45 views

Created a todo list in TS

I am learning Typescript and created a straightforward to-do list project to practice some basic concepts. I am able to Edit the todo Delete the todo Mark the todo as completed I want to how can I ...
user avatar
2 votes
2 answers
40 views

JavaScript code to check whether X won a tictactoe game

My code is already doing what I want, so it's functional, now my concern is, if there is a way to make it easier to read or even better and shorter my code, it's supposed to check if 3 'X' or 'O' are ...
user avatar
  • 21
0 votes
1 answer
45 views

Remove columns in HTML table where the sum is 0

I have an HTML table, and I would like to remove columns where the sum vertically is 0 dynamically. ...
user avatar
1 vote
0 answers
16 views

Taildwindcss dark mode toggle using javascript object

I'm learning javascript objects and ES6 and made this dark mode toggle for TailwindCSS. I'd like to know what can I improve with this code below ...
user avatar
3 votes
3 answers
71 views

Increment counter on button click

I've written a simple JavaScript function to increment a counter after clicking on a button. Here's my code: ...
user avatar
0 votes
1 answer
30 views

Show/hide depending on ID and Class

I have written some code that shows a div class, based on what ID is clicked. I'm a beginner, so not sure how to make this code compact, it seems way too long at the moment. Can anyone suggest a ...
user avatar
0 votes
1 answer
40 views

Range slider show/hides and reset (vanilla js)

I have a HTML5 range slider. i.e. ...
user avatar
0 votes
1 answer
32 views

Replace the src of an image for each link in a nav menu

I have this giant wall of code, which replaces the src of an img on the page with the one specified, for each link in a nav menu. But... it's a giant wall of code, calling up the action for each ...
user avatar
2 votes
1 answer
42 views

Javascript function which polls an async endpoint and inserts the result in a web page

I read about debounce this morning and ended up needing something similar to the concept in real life this evening to build a poll that checks whether a link I receive from an async call is ready to ...
user avatar
  • 21
3 votes
0 answers
60 views

Command line notebook

I used Python and a little bit of JavaScript using the (Python) modules Dominate and Flask to create a web app that somewhat resembles the Jupyter Notebook though with very basic functionality. I ...
user avatar
1 vote
0 answers
45 views

Changing game mode in Tic Tac Toe [The Odin Project] [closed]

I'm posting this here mostly as I posted it over at stackoverflow because the user that answered me recommended it: I'm learning to code with The Odin Project. So far, I've been doing every project ...
user avatar
  • 11
0 votes
2 answers
276 views

Sort table with ascending or descending order without a library

This is my first day coding, and I need help with sorting a table in ascending/descending order. The idea is that when a column is clicked it will sort in ascending order, and then it is clicked again ...
user avatar
5 votes
3 answers
460 views

Refactor JavaScript nested if-else

I'm really new to code optimization and JS. I would like to ask for help on optimizing my code. Thank you in advance. Here is my code: ...
user avatar
-2 votes
1 answer
39 views

undefined instead of innerHTML [closed]

element.parentNode.parentNode.children[3].innerHTML is fine but not ...
user avatar
6 votes
0 answers
96 views

Find and replace text in a webpage with JavaScript

I am new to web development and would like to get feedback on a JavaScript library that automatically finds and replaces text on a webpage using the MutationObserver interface. EDIT: Seeing that this ...
user avatar
1 vote
0 answers
164 views

Extract series of XML elements' values into an array

This code needs to extract data from in XML file. Specifically it needs to iterate over it, looking for a node called CHARGE_CODES that repeats over and over and ...
user avatar
  • 11
1 vote
1 answer
39 views

How to keep current HtmlElement active and change its properties?

I have a simple class that listens click and draws two points on the page. If first point is not exist it is drawn. When second point is present it should be changed after each click. I dislike this ...
user avatar
0 votes
1 answer
404 views

Using <a> element instead of <tr> to get clickable rows

I want to create clickable rows in an html table. Each row should be a link leading to a different page. I can of course add onclick handler, but that will create ...
user avatar
  • 101
3 votes
1 answer
107 views

Carousel Using Vanilla Javascript

As a beginner project, I've start working on this carousel slider that would slide through an image and a testimonial on click. The number of images and content slides would always be the same number. ...
user avatar
  • 33
2 votes
1 answer
102 views

Sticky Table Header in Plain JS

I wrote a code for sticky/fixed table header. I am bit confused with my coding, though it does my job. I know there are many jQuery codes available online. But I wanted to do it in plain JS with IE ...
user avatar
  • 21
2 votes
0 answers
57 views

Hashtable Visualizer in TypeScript

Implementation is based on the MVC design pattern, with callbacks to allow model and view to communicate with controller. Concerns: It's not ideal to have async code inside the model, i.e the model ...
user avatar
  • 429
2 votes
1 answer
1k views

Java CSV to XML converter

I'm relatively new to programming and I was trying to work a project. I would like recommendations of how to annotate or comment my project and any improvement I could make to it, any suggestion is ...
user avatar
6 votes
3 answers
468 views

Selecting elements from the DOM of a page

To get the book list from https://www.java67.com/2015/09/top-10-algorithm-books-every-programmer-read-learn.html , I am using the following code in the console of the firefox DevTools: ...
user avatar
3 votes
4 answers
326 views

Digital Clock Script

While learning JavaScript I thought it was a good idea to make a digital clock program. I followed a youtube tutorial (with some tweaks to my preference) and came up with my final code that I have. I ...
user avatar
12 votes
3 answers
765 views

Simple Calculator Script

I written my own calculator script in javascript! It is a basic one, but works really well. I am just wondering if there is any way to make this script more efficient & clean. On first look, I ...
user avatar
2 votes
1 answer
139 views

Recursive function with Promise and setTimeout to ping DOM

I use this function in browser automation. It pings the document in the browser to check if an element we are looking for is available (useful when there is JavaScript generated async content). If it'...
user avatar
  • 299
2 votes
1 answer
37 views

Creating multiple DOM buttons in JavaScript (I am not DRYing)

I am making a Tic-tac-toe game and I have the basic board but I am repeating the code and it is very badly written. I am wondering how I can use better practices to write the DOM elements that I need. ...
user avatar
  • 55
2 votes
1 answer
57 views

Generating a new web-page template and adding multiple new elements with pure JavaScript?

So, I am trying to generate a web-page template with JavaScript according to user specified values. I tested it with just background-color and made it working. I ...
user avatar
2 votes
2 answers
349 views

jQuery form.find radio class

In my application we have four inputs radio controls and on the load the value is checked to true. When the user select another radio and then save the form I want to get the new value. I am using the ...
user avatar
  • 521
1 vote
1 answer
123 views

Counting the number of click on the entire page

In an interview I was giving the following problem: Count the number of click on on the entire page. Can you think of a better way to do this? ...
user avatar
0 votes
1 answer
41 views

Code to modify DOM element using DOM.style property

So, I've a code that is below which works just fine: ...
user avatar
0 votes
0 answers
19 views

Is it possible to optimise jQuery tag:contains() selector?

I am trying to extract all the elements from a webpage which contains given set of words. E.g. Given I have an array of random words ...
user avatar
3 votes
0 answers
40 views

Displaying sections from pre-checked options

First off, not the greatest with jQuery but know enough to get by. I have a custom script for our WordPress site that ties in with a main plugin we use. I have a JSFiddle that gives the gist of what ...
user avatar
  • 51
1 vote
0 answers
1k views

Escaping invalid XML characters (e.g. for the Java DOM API)

I want to save and load an arbitrary Java String in a Text node in a XML file using the Java DOM API. The ...
user avatar
  • 111
2 votes
2 answers
54 views

Find size for elements to fit in certain width

This is a follow-up on Change size of elements until parent reaches certain height The goal of the function is to find a size for the elements inside a parent, so they all fit in a single row. I ...
user avatar
  • 75
4 votes
1 answer
53 views

Change size of elements until parent reaches certain height

I wrote this method and I would like to refactor it so it is easier to understand and looks cleaner. However, I don't know how or where to start. If you could give it your best shot and explain your ...
user avatar
  • 75
4 votes
0 answers
88 views

Enables markup to instantiate objects, call methods, and generate HTML

I created this package PXP. PXP enables markup to instantiate objects, call methods, and generate HTML. It works similar to a server-side templating engine, but rather than enforcing braces it ...
user avatar
  • 161
0 votes
1 answer
38 views

Jquery Selector optimization for multiple clicks

I have multiple inputs that each one has an increment and decrement button The buttons will be pressed multiple times so i am looking to optimize my selector: So should i keep the first one (which ...
user avatar
5 votes
1 answer
114 views

Video player UI in Javascript/JQuery

I am a Javascript/JQuery beginner working on my first ever project. Everything in this program is working as it should and I am happy with its performance. I have pieced it together from a variety of ...
user avatar
3 votes
1 answer
332 views

Simple Password Generator in JavaScript

...
user avatar
  • 41
6 votes
1 answer
342 views

Simple input class change with vanilla JS

I am just testing how I solved simple stuff. Goal: The aim is to expand the width of an input and collapse it. When mouseover ...
user avatar
8 votes
2 answers
1k views

Webpage with a preload animation using JavaScript setTimeout

I am working on a website with an animation that runs at the beginning before the content of the homepage becomes visible. I've looked at some examples of preloaders and now use that code with some ...
user avatar
  • 81
1 vote
1 answer
68 views

Automatically select the table rows between two selected rows

The code is to check the rows in a table. If in a table two non consecutive rows are checked then all the in between rows should be selected by itself. Also, after selecting two rows, on selection of ...
user avatar
2 votes
0 answers
294 views

Parse DOM Tree in C++ [closed]

Problem I need to read custom text input of a sample document object model (DOM) represented in a json format from a file and store it in a struct I've defined as ...
user avatar
  • 1,017
2 votes
1 answer
130 views

javascript carousel

I made this javascript code for a simple slider that can be controlled by arrows up/down. I'm wondering what I could have done better.. ...
user avatar
2 votes
1 answer
59 views

Add or remove a class on two elements when two different events fire

I want to add/remove a class on the html and body tags in the dom when my nav menu is opened or closed. Is this the most optimal way of writing this logic? ...
user avatar

1
2 3 4 5
9