Skip to content

Tag: html

Add class active on scroll. Vanilla JS

I’m new to vanilla js. I have a navbar with links to sections. I want to make the class active as soon as the section becomes active. If there are no active section, then remove the active class. Found such a script, but there is one drawback. If I am in an inactive section, the active class will remain…

Change aria attribute value using JavaScript Observer method

Can someone provide me with an example of an HTML div element with an attribute of aria-highlight that changes and notifies the element using the JavaScript observer method? An example would be using a checkbox that toggles the div and changes the background of the div element. I need this done in vanilla Jav…

Smart Drag Using JS?

Would it be possible to stop an element from dragging once it reaches the edge of the screen? I have been trying for the past hour with no luck. Here is my code so far: I thought I could use the clientHeight and clientWidth, but so far I have been unsuccessful. Any help would be much appreciated. Answer I ren…

Align input to the auto-height increase textarea

In my code, the other inputs are aligned at the center of the textarea as i type long text. What I want is to align the input boxes at the top of the textarea while the textarea is expanding downward. What i want example: enter image description here Answer just align the td’s to the top as shown below.