All Questions
Tagged with onclick javascript
7,603 questions
0
votes
4
answers
79
views
Button color-change on click, in React
I am trying to have a button to change its color when clicked in React.
I found this and tested it: https://reactgo.com/react-change-button-color-onclick/
The code being:
const [active, setActive] = ...
0
votes
1
answer
48
views
How to display 3 elements by 3 of an array in HTML using array.sclice() method in javascript
I have found a way to display a portion of an array using arrayName.slice(start, end), i made a funtion to feed the start and end to the slice method so i can use it with onClick button to click next ...
2
votes
1
answer
64
views
Drag and Drop Elements Independently in Vanilla JS
I'm new to Javascript, but getting close to finishing the vanilla JS for a mock desktop UI project: opening asides as "windows" that can be reordered, selected, and moved independently ...
0
votes
0
answers
38
views
button Element doesn't work on Iphones for some reason
I have tried to make something for Math class, however the button elements didn't seem to do anything on Iphones. I have tried to use eventlisteners and the onclick Attribute.
Does anyone know why it ...
1
vote
1
answer
39
views
Image alt captions showing as 'undefined' on modal image
I have mutiple art galleries on my website containing lots of images, I use an onclick event to pull up a full res, uncropped version of the image and it works perfectly fine. However, I want a unique ...
0
votes
1
answer
26
views
How can I conditionaly remove the default behavior of an anchor (a) tag added by insertAdjacentHTML
I am trying to add an anchor tag that should redirect the user to another page only if a condition is met (here if array.length<3). I have followed Iananswer of this SO question, but in my case I ...
0
votes
4
answers
75
views
Combining 2 addEventListeners which do the same thing into 1
I would like clicking div-1 and div-2 to do the same thing but please how can I combine the 2 eventlisteners functions into 1
var div_1 = document.getElementById("div-1");
var div_2 = ...
2
votes
3
answers
62
views
Run custom function before open in new tab
I am using an <a> tag instead of a button because I need to add the feature that allow user to right click and then open in new tab:
The issue right now is that this tag have an onClick ...
0
votes
1
answer
71
views
Execute the same javascript function from different onclick events [duplicate]
I have the following javascript code that plays a video when I click the "play" button in HTML.
How can I play different videos (multiple play buttons in HTML) without duplicating the ...
0
votes
1
answer
56
views
Responsive navbar click
I try to get my navbar responsive. Follow this tut on w3schools. If I copy and paste it is working, but I want it to be mobile first (media queries) and there is my problem.
The switch from mobile to ...
0
votes
1
answer
50
views
Using a class to open same popup using document.querySelector
I have a popup login box on my site, I use <a class="logincontent">Login</a> which then calls up this function:
document.querySelector('a.logincontent').onclick = () => {
...
1
vote
1
answer
48
views
js element.click() on focusable element does not shift focus to that element
I stumbled across this behaviour. I want that an input element receives focus, if you click it, so that it becomes the documents' active element. The click is generated programmatically via javascript ...
0
votes
0
answers
26
views
react-draggable issue on mobile devices
I have an issue with react-draggable library, when on mobile or tablet devices onClick from children are not propagated. Anyone knows which might be the reason?
<Draggable onStart={handleDragStart} ...
0
votes
0
answers
21
views
How to add a class and remove when clicked, or when clicked elsewhere? [duplicate]
I have a caret dropdown that is supposed to do an up and down animation on 4 different tabs. In general scheme of things, these tabs populate different content when clicked on. The problem here is ...
1
vote
1
answer
52
views
How to change content in an onclick function for all elements inside a button tag?
I have a layout where if the image and/or text are clicked, then it populates different information below it. If I have an img and paragraph inside the button, it will only work if you click anywhere ...