Questions tagged [javascript-events]
DO NOT USE THIS TAG! JavaScript has no event constructs. Use [dom-events], [jquery-events], [backbone-events]; or library/environment + [events] e.g. [node.js]+[events]
3,176
questions
0
votes
2
answers
119
views
I need to stop the current event jquery
THIS HTML CODE
<div id="functionality" style="padding: 10px 20px;">
<span class="btn btn-xs btn-success" style="margin:2px; float: left;">flat earth account</span>
<span ...
0
votes
3
answers
1k
views
Trigger Javascript change event when value not different (file input)
"Form" with client-side only interactivity:
<input type="file" id="file" />
I'd like to avoid making another button just to trigger functionality, but:
function handleInput(e) {
console....
0
votes
1
answer
273
views
Immediately Invoked functions in javascript
I have a clarification in using IIFs in javascript .
I have downloaded a javascript file called called test.js as follows and I have got following questions after googling IIFs:
define(function () {
...
0
votes
2
answers
117
views
How do I get JS popup to position on Load? On Resize works
I created a simple popup in jQuery, and almost everything seems to work fine except for the on load in the infoPopupLoadResize() function. I'm not sure why it isn't firing on page load, but does work ...
1
vote
1
answer
202
views
Javascript - start and stop with keypress from keyboard
I have this javascript http://jsfiddle.net/ZDsMa/433/ to pick a random number. I put this on html div and i want to start scrambling the numbers with keypress instead of onClick, also to stop again ...
1
vote
0
answers
31
views
Remove all event listeners in a Funtion via function reference
I have a function that is implicitly called in another function: for example I have a function like :
function a() {
window.addEventListener("hashchange", function() {
// some stuff...
});
}
and ...
-2
votes
2
answers
44
views
About javascript events
<script>
function displayDate() {
document.getElementById("demo").innerHTML = Date();
}
</script>
<script>
function displayDate() {
document.getElementById("demo").innerHTML ...
0
votes
1
answer
32
views
Animations not playing on load or on click in Javascript
Working on a tip calculator with an animation on an h1 tag and a slideDown and slideUp on click on the h2 tags. Problem is, none of the animations are playing and the click event isn't working either....
5
votes
1
answer
219
views
If I bind a JavaScript event to an element, then delete the element, what happens to the event?
Let's say I have an element:
<section id="container">
<div id="curious">hey, there</div>
</section>
Then, after the DOM loads, I bind an event to the element, like so:
$(...
1
vote
3
answers
129
views
how to stop an Event to run again in simple javascript?
My Code is below .
Now what i want is that ,the event execute only on first mouseover after that it should become disable. which means if user mousover again it should do nothing **
**Thanks
HTML ...
0
votes
1
answer
66
views
Mousemove gets fired only when mouse is over div?
Why is the mousemover event fired only when the mouse is over #cursor?
function test(event) {
console.log(42);
}
#cursor{
width: 30px;
height: 30px;
background: green;
}
<div ...
0
votes
1
answer
3k
views
Add multiple inputs dynamically
I have a form with 2 inputs where, when the user selects a description from the datalist the second input is filled with the product. It works fine -> bootbly1
Now I want to add dynamically inputs in ...
0
votes
0
answers
32
views
Mouse events start being ignored after some time under some conditions
I developed a jQuery plugin which has a 'reset' function which basically removes certain DOM elements, apply some CSS and restore the original DOM element (the one to which I apply the plugin) state.
...
0
votes
0
answers
34
views
Why should I click twice for keypress when I put keypress event in click event?
var main = function() {
$('.article').click(function() {
$(document).keypress(function(event) {
if (event.which === 111) {
$('.current').children('.description')...
0
votes
0
answers
51
views
function not defined error
for (r in resArray) {
$(".results li").remove();
var title = resArray[r]._source.title;
var year = resArray[r]._source.year;
var typeOfDrawing = resArray[r]._source....
1
vote
2
answers
998
views
Unbinding jQuery Click Event doesn't always work
Have a look at
http://jsfiddle.net/60j9hhz7/3/
UPDATED FIDDLE (use this)
http://jsfiddle.net/60j9hhz7/10/
html:
<div class="mycontainer">
<a href="#" class="test">test</a>
&...
1
vote
0
answers
61
views
How to get notified when an element is made visible on the page?
It's clear to me how to check if an element is visible on the page, by using the functions explained on this question.
//Where el is the DOM element you'd like to test for visibility
function ...
0
votes
1
answer
92
views
jQuery delegate() / on() - force order of events
Perhaps a silly question but...
In this simple code:
$(".Q").on("click", ".container", containerClick);
$(".Q").on("click", ".container .oneElement", oneElementInContainerClicked);
if ....
0
votes
1
answer
36
views
Javascript not able to enable button due to condition
I have a pure JS below which is not working as it have to meet the conditions then the button would be enabled.
It's able to work on jsfiddle but just not in codes.
I remove the other condition to ...
1
vote
2
answers
124
views
remove label message on keydown - javascript
quick question, my prompt is working okay, when someone leave the phone input field blank my label message shows, but how do I remove the message, when they go back to the input field on click down?
...
1
vote
1
answer
272
views
Jquery use button for multiple click events
I would like to be able to click a button to enable a text input for editing and then click it again when I am done which will fire off the ajax to save it. I am reading the doc's for on() and off() ...
0
votes
1
answer
120
views
window.addEventListener is not working
Can you please help me understand where the code is wrong. The below code doesn't invoke the event handler for window.onload event.
<!DOCTYPE HTML>
<html>
<head>
&...
7
votes
2
answers
26k
views
Javascript - Emulate a space bar keypress
I've searched everywhere, read the docs on MDN, but I can't seem to solve this problem.
I want to emulate the client pressing the space bar using Javascript.
I've tried:
var e = new KeyboardEvent('...
0
votes
3
answers
181
views
Detect change in input element, set with javascript
I have a slider connected to an input element. I have no control on the slider implementation. Whenever the slider is moved, the input element value is updated. I can check that with $('#my-input')....
-3
votes
1
answer
119
views
What is this code doing
In this code below could you describe the elements of the code and what is occurring?
Please help me to understand what this is doing? I have to figure what this code is doing. I know it is java ...
0
votes
1
answer
435
views
Facing issue in triggering keypress event in javascript
I want to fire Tab key's keypress event on a specific condition, but I'm getting error.
Error: Uncaught TypeError: event.initKeyEvent is not a function
Code
function simulateKeyPress(element) {
...
0
votes
1
answer
97
views
Changing images onclick not working
I want the image to change when someone clicks on it.But this isn't working.
<image id="s" src="s.jpg" onclick="reaction()" ></image>
function reaction()
{
var replace=...
0
votes
1
answer
35
views
Jquery has() vs parents()
I want to check if event target is descendant of specific wrapper.
Should i use has() function or parents()?
if($('.wrapper').has(e.target).length){
//do something
}
vs
if ($(event.target).parents(...
1
vote
1
answer
3k
views
How to wait until onload event completes its work in JavaScript?
I'm developing a printing tool using HTML5 canvas. As a test, I've tried to draw an image and a rectangle on the canvas, and then copy it to a new window for printing, using the code below. But all I'...
1
vote
0
answers
79
views
Mapster - how can I open an alert if every area is selected?
first of all: I am not a Java-guy! I am just using it while building html-sites.
Now my Problem:
I want to build a little search picture. So I have defined using mapping some areas in a picture and ...
0
votes
1
answer
365
views
Object doesn't support property or method 'attachEvent' in ie8 when attackhing an even
I still need a vanilla JavaScript solution to attach an event handler in Internet Explorer 8. When I do below code I got an error in ie8 saying Object doesn't support property or method 'attachEvent'. ...
0
votes
3
answers
1k
views
Custom validation message for a select
I have this select input field where I want to validate its selected field using javascript - and then show a html5 error message (and make its border red) if "01" is selected in the select input ...
3
votes
1
answer
1k
views
How can I use slideToggle() with a duration and easing?
I am making a sliding menu using jQuery and the bounce jQuery UI effect. The problem is that the hover event doesn't activate even once when I hover over the first li element. Here is my JavaScript ...
0
votes
2
answers
91
views
Remove event handler if I don't know the original selector used to create this handler
I want to unbind the event handler from the element.
The handler is created by a 3-rd party plugin and I don't want a behavior it produces.
Correct me if I wrong but 'off()' and 'unbind()' functions ...
0
votes
1
answer
194
views
Dynamically added text field have default value of first text field
I have a script where I can add text fields with "Add Button" but the rest of fields get default value of first field. You can check the demo here. Just type Apple in item field in demo and you will ...
-1
votes
2
answers
2k
views
How to apply multiple events on single HTML text field? [closed]
I want to call a function through multiple events "onBlur", "onKeyup" and "onClick" but my script is working only on first event.
My Code :
<input type="text" onBlur="getprice(this),getdesc(this)...
1
vote
1
answer
34
views
Trying to change colour of a button to show which images is displayed with javascript
I'm trying to change colour of a button to show which images is displayed with javascript.. Something similar to :Active in CSS... I've been looking for hours, i've managed to change just about every ...
2
votes
2
answers
5k
views
removeEventListener and anonymous function with arguments
I have a text input where I add a event listener.
This event listener execute a anonymous function by onkeyup.
This anonymous function contains a foo function.
This foo function have an argument ...
-1
votes
2
answers
215
views
Javascript : removeEventListener doesn't work
I have a first button where I add an event listener to execute foo function.
The foo function just displays a number in console.
I have a second button for removing the event listener added.
Here ...
0
votes
2
answers
3k
views
How to disable the clicking of any element on the page after a jquery click
I'm trying to disable the entire page by not allowing any further clicking anywhere on the page once already clicked. I'm aware there are so many sources with similar context, but didn't quite find ...
1
vote
2
answers
83
views
on click event in javascript not triggering [duplicate]
I am using JQuery sortable and have two two lists that I am moving items from one to another. The first move works just fine with a double click. Now that it is in the second list, I want to allow ...
2
votes
1
answer
1k
views
Disable scroll but still track when user attempts to scroll
Quick disclaimer–I know there are similar questions but they don't provide the answer I'm looking for.
I'm trying to disable scrolling entirely when the page loads but still be able to listen to when ...
0
votes
2
answers
38
views
How to add new text to the textarea without deleting the older one when an event triggers using js for example clicking button
This is a simple cart add program.If i Click the add Add button i need to add the selected content on the text area but when i add the second item my first item was deleted and my text area is reset ...
1
vote
1
answer
56
views
key up jquery removing class
Demo
I have here a demo on validating if a class exist in a div.
when there is no class another class is removed from a button.
Basically what this does is when there are no disabled button the ...
0
votes
1
answer
31
views
Variable redefined by fast clicking?
I am running into an issue with my code. If a user clicks very quickly, it is possible to redefine the originalHeight value, which I am battling to wrap my head around. Could someone point me in the ...
0
votes
1
answer
143
views
DomContentLoaded event on image preview pages
For example I have some image src.
I open this page in the new chrome tab.
On the page I have script that runs on DOMContentLoaded event:
document.addEventListener('DOMContentLoaded', function() {
...
0
votes
1
answer
31
views
Image changer in javascript
I have tried many different ways to implement this. I have been able to use a button to change the image, but when I add the rest of the code to make it automatic, I cant get it to work. Here is my ...
-1
votes
1
answer
10k
views
How can I close the current browser tab when the user click on a button using JavaScript? [duplicate]
In a page I have a 'Close' button that when clicked has to close the current browser tab (the tab in which is the page that contain this close button). So I wrote something like this:
<button type=...
13
votes
1
answer
5k
views
Is triggering event listeners using ".click()" asynchronous?
I have the following code (where there is a <button id="7"> in my HTML):
(function() {
'use strict';
document.getElementById(7).addEventListener("click", function(){
console.log('...
0
votes
1
answer
53
views
why does my eventListener never fire?
I have the following code,
function expandTextarea () {
var textareas = document.getElementsByTagName('textarea');
for (var i = 0; i < textareas.length; i++) {
if (textareas[i]....