FAQ Database Discussion Community


Track Links Using Events - Race Conditions

javascript,angularjs,javascript-events,google-analytics,adobe-analytics
I am building AngularJS applications which have common header with links to each of the application: <a href="https://app1.company.com">App1</a> <a href="https://app2.company.com">App2</a> Each application is running on its own subdomain and when user clicks a link on the header - page redirects to that application. I have to track user actions with...

what does onclick='mycheck(“+i+”)' do?

javascript,javascript-events
Im fairly new to javascript and would appreciate your explaination on this code. i was provided with the below code as an example and needed to make some changes too it but im unsure what onclick='mycheck("+i+")' is meant to do. i know its calling the function mycheck() but not sure...

Onclick event triggering onload for button

javascript,jquery,html,javascript-events
I have a div, and I want to append a button created with JS to it, with JS defining the ID, onclick, as well as the text. Everything works fine, except for the onclick event triggers on page load instead of when clicked. When inspected, there isn't even a onclick...

Can't Add Up Radio Button Values with jQuery

javascript,jquery,html5,jquery-mobile,javascript-events
I'm trying to add up all the values of the radio buttons selected on Submit button press. It sometimes changes the 0 to a 200, but it isn't adding correctly. I'm not quite sure what is going on with this one, since the total amount sometimes changes, but isn't accurate....

Bind multiple events in javascript

javascript,html,javascript-events
I tried the following to change a span to red on mouseover and black on mouseout: <span onmouseover="this.style.color='red' onmouseout=this.style.color='black'">Mouse over me!</span> but it does not work! How can I bind more than one event to a single element using javascript?...

does jquery .on() support for “load” or “ready” events?

javascript,jquery,javascript-events
For attaching click event handler to dynamically loaded html ,I could use : $(document).on("click", "Parent_SELECTOR_Available_In_Initial", function(e){ /// Do some stuff ... }); I dynamically load some html mark up and java script which contain methods need to be run on ready or load event . But $(document).on("ready", "Parent_SELECTOR_Available_In_Initial", function(e){ ///...

EventTarget.addEventListener()'s useCapture argument use?

javascript,javascript-events
I am studying the vanilla JavaScript and I have some trouble understanding what is the use of this useCapture argument in the EventTarget.addEventListener() function. https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener useCapture Optional If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched...

How to get a button's ID when clicked in Windows 8 apps?

javascript,html,javascript-events,click,windows-8.1
I'm trying to get the ID of the button I clicked but I can't do it. I tried everything but it doesn't work. How can I do this? ...

JQuery event propagation (return false)

javascript,jquery,javascript-events,event-handling
Why clicking on the male radio button does not work? <div id="m_wrapper"> <input id="m" type="radio" name="sex" value="male" />Male<br> </div> <input id="f" type="radio" name="sex" value="female" />Female <input id="o" type="radio" name="sex" value="other" />Other $("#m_wrapper").click(function(e){ $("#m").prop('checked', true); return false; }); I know that here -> return false is equivalent to call e.preventDefault() AND...

JavaScript events and bubbling

javascript,javascript-events,event-bubbling
I have the following (simplified) markup code: <div id="container"> <div data-value="1"> <span>Click me 1</span> </div> <div data-value="2"> <span>Click me 2</span> </div> </div> <div id="messages"></div> I want to take advantage of bubbling by attaching an event listener only on the #container, and get the clicked children's data-value. document.getElementById('container').addEventListener('click', function(e){ document.getElementById('messages').innerHTML =...

How can fetch the text from html tag in meteor template event?

jquery,templates,javascript-events,meteor,meteor-helper
How can I get "option 1" from below code: <template name="MyTemplate"> <div class="dropdown"> <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#" aria-expanded="false"> <button type="button" class="btn btn-sm btn-primary">Add</button> </a> <div class="dropdown-menu dropdown-alerts"> <form method="post" id="some-form" data-remote="true" accept-charset="UTF-8"> <div class="form-group"> <label>Select Option</label> <div class="input-group">...

AngularJS - Click event (in directive) triggers when anywhere in the parent is clicked

javascript,angularjs,javascript-events,angularjs-ng-transclude
I'm going to do my best to explain my issue - bear with me. This whole thing is a directive for file selection: The directive has an ng-transclude component that contains a few directives, contained in their own divs. Parent directive: <div class="extra-cells"> <div ng-transclude class="extra-cells-row"></div> </div> ng-transclude content: <div...

Javascript onpaste event of everytext box value should be split and paste in corresponding textbox

javascript,javascript-events
Strictly no jquery please I have text 1234ABC984IK4H2J and I have four text box onpaste i need text to split and copied in remaining text box Purely in javascript no jquery as my application doesn't support jquery and IE>8 functions so no function supports like querySelectorAll and addEventlistener HTML <td><input...

Setting the onclick event to a custom function results in syntax error

javascript,javascript-events,onclick
Given the following example code I want to set the onclick event to a function which I declare in the same method (no function in global scope): <HTML> <HEAD> <Title>Title</Title> </HEAD> <body> <img id="img" class="std" src="http://www.free-animated-pictures.com/bug_crawls_on_screen.gif"/> <script type='text/javascript'> var i = document.getElementById("img"); var func = function(){ var i = document.getElementById("img");...

Avoid onRowClick event when outputLink is clicked inside of RichFaces datatable

javascript,javascript-events,datatable,richfaces
How to avoid the call to onRowClick on the datatable on the column that has the outputlink (target to a new window)? <rich:dataTable id="dt" value="#{bean.cars} var="_car"> <a:support event="onRowClick" action="#{action.navigateToCarDetails(_car.id)}"/> <rich:column> <f:facet name="header">Select</f:facet> <a:commandLink onclick="Event.stop(event)" action="#{bean.toggleSelectedCar(_car.id)}" reRender="dt" ajaxSingle="true" limitToList="true"> <h:graphicImage...

Conditionally include script for browsers

javascript,jquery,javascript-events,reference,conditional-statements
I have such kind of script code setTimeout(function () { $('.grayscale .inactive img').each(function () { $(this).wrap('<div style="display:inline-block;width:' + this.width + 'px;height:' + this.height + 'px;">').clone().addClass('gotcolors').css({ 'position': 'absolute', 'opacity': 0 }).insertBefore(this); this.src = grayscale(this.src); }).animate({opacity: 1}, 500); $(".grayscale li").hover(function () { $(this).find('.gotcolors').stop().animate({opacity: 1}, 200); }, function () {...

Can a conditional-And operator(&&) contain more than 2 operands?

javascript,html,events,javascript-events
I asked a question in regards to this code earlier and it works to a degree after I changed it to reflect the answer but there is a bug that only really you to match red with red or blue with blue or green with green. I know that the...

How do I avoid hover event to fire in iPhone and iPad?

javascript,ios,iphone,javascript-events,jquery-hover
I had added an effect on hoverEnter and hoverLeave on my Divs assuming that these events wont fire on iOS devices. But on iOS devices the hoverEnter and click event fire and the hoverEnter effect is maintained. I dont want these hover events to fire on mobile devices. What should...

How to reset the complete document after opening it?

javascript,pdf,javascript-events,reset,acrobat
i want to reset the complete form after opening it. I have tried this: page.open = this.resetForm(); But it doesn't work. Im using Acrobat Pro DC....

WebApp doesn't recognize that an input field was changed when set with jQuery in PhantomJS

javascript,jquery,javascript-events,phantomjs,html-input
I open telegram with PhantomJS and try to fill phone number input with evaluate page like below: page.evaluate(function(){ $("input[name='phone_number']").val("123456789"); }); When PhantomJS clicks on next button with jQuery the alert massage says "tel input is empty" but when the page is rendered we can see numbers in the input field....

Why isn't my Google Tag Manager event listener being installed?

javascript-events,google-analytics,google-tag-manager
I have a very simple Google Tag Manager trigger that looks like this: I also have a corresponding tag that uses this trigger. I have published my container, and the tag shows up when previewing/debugging the container: I also see my link's id in the response from GTM. However, I...

dynamically added event handler disables the previous one in Javascript

javascript,javascript-events,event-handling
I am creating buttons dynamically in Javascript. Also adding dynamically an eventhandler to each button. For the last button it works but the previous ones simply are not working any longer. Here's my small piece of code. What do I do wrong? <html> <head> <script> var id = 0; function...

Why am I getting an uncaught type error with the following code?

javascript,javascript-events
The purpose of this code is to have 3 divs that change color when clicked and when the two colors in divs on the left make up the one on the right the user receives a positive message either on the console or the DOM. I thought I had this...

How to prevent my jQuery textarea Focus event from firing repeatedly for ulimted times in a row

javascript,jquery,javascript-events
I have something like the basic JavaScript jQuery code below that is only called once in my project code however it alerts 100+ times when my textarea attached to the event is focused by clicking my mouse cursor into it! projectTaskModal.cache.$cmtTextarea.on('focus', function() { alert('ON FOCUS EVENT'); }); My goal is...

On condition fire all events, else fire none

javascript,jquery,javascript-events
I am working on top of existing javascript (that I can not alter) and need to check something on submit. If my condition is true, no other submit handlers should be applied. If my condition is false, all other submit handlers shall be applied. What I have tried so far:...

How do I know, via key event code, if the character just entered in a