tagged [javascript]

var functionName = function() {} vs function functionName() {}

var functionName = function() {} vs function functionName() {} I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code an...

14 Feb at 07:44

How To Determine Which Submit Button Was Pressed, Form onSubmit Event, Without jQuery

How To Determine Which Submit Button Was Pressed, Form onSubmit Event, Without jQuery I have a form with two submit buttons and some code: HTML: JavaScript: ``` form.onSubmit = function(evnt) { // D...

13 Feb at 23:32

How can I integrate Python and JavaScript?

How can I integrate Python and JavaScript? Is it possible to integrate Python and JavaScript? For example, imagine you wanted to be able to define classes in JavaScript and use them from Python (or vi...

Capture HTML canvas as GIF/JPG/PNG/PDF?

Capture HTML canvas as GIF/JPG/PNG/PDF? Is it possible to capture or print what's displayed in an HTML canvas as an image or PDF? I'd like to generate an image via canvas and be able to generate a PNG...

11 Feb at 20:18

How to create a file in memory for user to download, but not through server?

How to create a file in memory for user to download, but not through server? Is there any way I can create a text file on the client side and prompt the user to download it, without any interaction wi...

Remove all child elements of a DOM node in JavaScript

Remove all child elements of a DOM node in JavaScript How would I go about removing all of the child elements of a DOM node in JavaScript? Say I have the following (ugly) HTML: And I grab the node I w...

7 Feb at 17:47

Stop form refreshing page on submit

Stop form refreshing page on submit How would I go about preventing the page from refreshing when pressing the send button without any data in the fields? The validation is setup working fine, all fie...

7 Feb at 15:53

How can I remove a specific item from an array in JavaScript?

How can I remove a specific item from an array in JavaScript? How do I remove a specific value from an array? Something like: Constraints: I have to use JavaScript. Frameworks are not allowed.

6 Feb at 14:23

redirect after a fetch post call

redirect after a fetch post call I am creating an social login page with an Access Management (AM) server. When user click on the login button then I make a fetch http post call to AM server. AM serve...

5 Feb at 09:36

setState doesn't update the state immediately

setState doesn't update the state immediately I would like to ask why my state is not changing when I do an `onClick` event. I've search a while ago that I need to bind the `onClick` function in const...

DOM element to corresponding vue.js component

DOM element to corresponding vue.js component How can I find the vue.js component corresponding to a DOM element? If I have Is there a vue method equivalent to the jQuery

2 Feb at 06:55

How to get the image size (height & width) using JavaScript

How to get the image size (height & width) using JavaScript Is there a JavaScript or jQuery API or method to get the dimensions of an image on the page?

31 Jan at 23:41

Javascript onHover event

Javascript onHover event Is there a canonical way to set up a JS `onHover` event with the existing `onmouseover`, `onmouseout` and some kind of timers? Or just any method to fire an arbitrary function...

28 Jan at 21:50

How do you use the ? : (conditional) operator in JavaScript?

How do you use the ? : (conditional) operator in JavaScript? What is the `?:` (question mark and colon operator aka. conditional or "ternary") operator and how can I use it?

27 Jan at 16:15

Are double and single quotes interchangeable in JavaScript?

Are double and single quotes interchangeable in JavaScript? Consider the following two alternatives: - `console.log("double");`- `console.log('single');` The former uses double quotes around the strin...

27 Jan at 05:37

JavaScript .replace only replaces first Match

JavaScript .replace only replaces first Match But the replace functions stop at the first instance of the " " and I get the Result: `"this%20is a test"` Any ideas on where I'm going wrong I'm sure it'...

27 Jan at 04:14

How to do a redirect to another route with react-router?

How to do a redirect to another route with react-router? I am trying to do A SIMPLE thing using react-router ( ) to redirect to another view. ``` import React from 'react'; import {Router, Route, Link...

25 Jan at 00:39

ReactJS call parent method

ReactJS call parent method I'm making my first step in ReactJS and trying to understand communication between parent and children. I'm making form, so I have the component for styling fields. And also...

24 Jan at 21:58

Conditional Validation in Yup

Conditional Validation in Yup I have an email field that only gets shown if a checkbox is selected (boolean value is `true`). When the form get submitted, I only what this field to be required if the ...

24 Jan at 08:48

How do you access the matched groups in a JavaScript regular expression?

How do you access the matched groups in a JavaScript regular expression? I want to match a portion of a string using a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) and then a...

21 Jan at 19:24

Loop (for each) over an array in JavaScript

Loop (for each) over an array in JavaScript How can I loop through all the entries in an array using JavaScript?

How to append text to a div element?

How to append text to a div element? I’m using AJAX to append data to a `` element, where I fill the `` from JavaScript. How can I append new data to the `` without losing the previous data found in i...

20 Jan at 21:7

Mongoose - What does the exec function do?

Mongoose - What does the exec function do? I came across a piece of Mongoose code that included a query findOne and then an exec() function. Ive never seen that method in Javascript before? What does ...

19 Jan at 21:30

How to set 'X-Frame-Options' on iframe?

How to set 'X-Frame-Options' on iframe? If I create an `iframe` like this: How can I fix the error: > Refused to display `'https://www.google.com.ua/?gws_rd=ssl'`

19 Jan at 01:54

What is the cleanest way to disable CSS transition effects temporarily?

What is the cleanest way to disable CSS transition effects temporarily? I have a DOM element with this effect applied: I am writing a jQuery plugin that is resizing this element, I need to disable the...

13 Jan at 20:26