I am trying to change the big image when another small image is clicked, kind of like a product display on an e-commerce website. But my code doesn’t seem to work. Answer Don’t repeat JavsScript code. Instead delegate a click to every .button-container’s img element: Another suggestion is no…
Tag: html
Javascript event listeners and arrays
I am trying to recreate a scratch-to-reveal-image effect with 3 images in an array triggered by 3 buttons. My event listener is not working, as you can see, it shows the same revealed images no matter the button. The event listener syntax has confused me a bit and I would like some help on that specifically. …
Error in *ngIf on one element not letting *ngFor to work properly on another
Initialization of variable in one element and error in console that I had been ignoring all along, created a problem elsewhere in another element. Why does angular behave this way? When I do not initialize another variable, which I am using with *ngIf, javascript throws up “undefined” while testin…
why js closest method not find sibling element?
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… …
traffic light sequence, html, javascript and css
I am trying to make a program that displays a traffic light sequence. I have made a mistake in the code so it doesn’t get past showing the red light when the “starts sequence” button is clicked. if you can see where I went wrong please help me get it working. I have used functions to change …
Use an image as a mask for another image
I’m making a website that I wanted to be a white page that you could stamp to make another image appear under. So when you click, you make a holepunch. Like this exemple : So I managed to have a randomized image in the background as I click which is fine for what I want, and to be able to
JavaScript Show invisible divs on click
I ran into a problem that when I click on the button, it just flips the icon but only makes the invisible fields visible on the second click. Are there any idea how to do it? (Heres a gif to show my problem: https://ibb.co/cvz7pWC ) Also heres my code : Answer This could be to do with you not being
How to remove getbutton.io branding
If we use this free getbuttton.io widget then it shows getbutton.io branding so, is there any way to remove that branding using JS? Answer it will take like 2 seconds to load. so you can do something like this. you can increase 2sec to 5 if it takes more time to load.
How to use If Else in OnChange() event in JavaScript?
This is My HTML code: And JS Code: Whenever onchange() event occurs I want to display Cost Of Ticket according to the selected value of select. But it shows 25000 after onchange() event and then never changes irrespective of the values selected. How to correct the code to complete above task? Answer Let me te…
Button that generates error message on condition
I am trying to implement a button in HTML that calls a function on click, which checks whether a textinput is empty. If so (the information hasn’t been entered), an error message for the input field should be generated. I am experimenting with a button that doesn’t submit the form. However, if you…