javascript-events

Remove and replace another onclick function in a div through Pure Javascript?

偶尔善良 提交于 2019-12-12 04:38:49
问题 I have this below span div and I copy this to another place in the DOM. But the onclick function I need to remove and place another onclick function. <span class="plus childNode1" onclick="expand_collapseChildnodes('childNode1')" id="abc"></span> Here I have to remove the onclick="expand_collapseChildnodes('childNode1')" for the copied element and replace it with onclick="checkNodes('childNode1')" 回答1: Consider a sample HTML page: <html> <head> </head> <body> <div id ="d1"> <span class="plus

Mootools: How to Disallow `mouseenter` and `mouseleave` event when checkbox checked?

安稳与你 提交于 2019-12-12 04:35:33
问题 Mootools: How to disallow mouseenter and mouseleave event when checkbox checked ? window.addEvent('domready',function() { var z = 2; var e = document.id('draggable'); var drag = new Drag.Move(e, { grid: false, preventDefault: true, onStart: function() { e.setStyle('z-index',z++); } }); //e.store('Drag', drag); var w = e.getStyle('width'); var h = e.getStyle('height'); e.set("morph", {duration:700,delay:400}).addEvents({ mouseenter: function(){ this.store("timer", (function() { this.morph({

How to use a Google map event listener to pass a variable and submit a form

假装没事ソ 提交于 2019-12-12 04:18:19
问题 I'm following a Google Maps v3 demo gallery example here, which is a rectangle overlay. I modified the rectangle to make it clickable. rectangle = new google.maps.Rectangle({ map: map, clickable: true }); Then I added an event listener to the rectangle google.maps.event.addListener(rectangle, 'click', editSite); and made a method to cause the form to submit, and it worked properly. function editSite() { document.getElementById("siteSelection").value = 22; document.siteSelectionForm.submit();

how can i add click evet to my rapahel pie chart?

旧时模样 提交于 2019-12-12 04:15:47
问题 How can I add click event to my Rapahel pie chart ? var r = Raphael("holder-1",340, 185); pie = r.g.piechart(150,85, 75, values , {legend: labels, legendpos: "east"}); i got the answer it is pie.click(function () { }); can i pass value to the onclick event ?, here can i pass values and labels to onclcik function ?? 回答1: According to the docs for the node attribute, you should just be able to attach events as you would any DOM element using it: pie.node.onclick = function () { /* Something */

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

淺唱寂寞╮ 提交于 2019-12-12 04:07:09
问题 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 type="text" id="id1" maxlength="4" size="4" onpaste="paste();"></input></td> <td><input type="text" id="id2" maxlength="4" size="4" onpaste="paste();"></input></td> <td><input type=

How to pass parameters to a function being passed as an argument of addEventListener or being assigned to an event handler?

帅比萌擦擦* 提交于 2019-12-12 04:00:33
问题 What is the correct and professional way to add parameters to a function being passed to addEventListener() or or being directly assigned to an event handlers as in el.onclick = doSomething(param); 回答1: You can use an anonymous function when you need to pass parameters to another, like this: el.addEventListener("click", function() { doSomething(param); }, false); Whereas if it didn't need parameters, it would just be: el.addEventListener("click", doSomething, false); 来源: https://stackoverflow

How to get values in window.location.href? [duplicate]

百般思念 提交于 2019-12-12 03:59:11
问题 This question already has answers here : How can I get query string values in JavaScript? (73 answers) Closed 6 years ago . Code: window.location.href = "Posts?Category=" + sel; How to get the value in Category page? 回答1: Try this: function getURLParameter(name, urlsearch) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(urlsearch || location.search) || [ , "" ])[1].replace( /\+/g, '%20')) || null; } var url = "Posts?Category=1134324"; alert

Detect a right-click on Ace editor

假装没事ソ 提交于 2019-12-12 03:58:38
问题 Is there a way to detect a right-click event on Ace editor? I've being trying to add a listener like this: editor.session.addEventListener('contextmenu', function(e) { e.preventDefault(); alert('success!'); return false; }, false); and this editor.addEventListener('contextmenu', function(e) { e.preventDefault(); alert('success!'); return false; }, false); but without success. Thanks! 回答1: add event listener on the element containing the editor editor.container.addEventListener("contextmenu",

What is Javascript atomic execution unit for events?

拟墨画扇 提交于 2019-12-12 03:53:31
问题 The javascript engine is executing a function which in turn calls another function (sequentially) and this goes on for say 5s. Meanwhile, several events were triggered either by the user or programmatically. Can we take for granted that no event will be handled before the outermost function finishes? /* Example */ function outermost_function() { function inner_function () { function innermost_function () { return; } } } 回答1: Javascript is single threaded and events are queued in an event loop

Flow control in JavaScript

筅森魡賤 提交于 2019-12-12 03:49:49
问题 Is it possible to write this flow control in JavaScript? MyLib.get = function() { /* do something */ next(); }; MyLib.save = function() { /* do something */ next(); }; MyLib.alert = function() { /* do something */ next(); }; MyLib.flow([ MyLib.get(), MyLib.save(), MyLib.alert() ], function() { // all functions were executed }); 回答1: Yes, but two things to know: You should build the array from references to your functions. That means you leave off the () , because you just want to pass through