addeventlistener

How to set value of one input field based on another input field?

纵饮孤独 提交于 2021-01-29 12:20:45
问题 I am trying to set the value of slug field by manipulating the input of another field title using JavaScript. When I type in the slug and then again i start typing in the title field the value of slug field doesn't get updated. here is my form document.getElementById('title').addEventListener("input", function(){ let title = document.getElementById('title').value; console.log(title); title = title.toLowerCase(); title = title.replace(/\s+/g, '-'); document.getElementById('slug').setAttribute(

addEventListener with ruturn in AS3 - How?

时光毁灭记忆、已成空白 提交于 2021-01-29 08:26:54
问题 I'm a new Flash AS3 job but I have a big problem using some OOP concepts like return from methods, when I needs a Event Listener code. The problem is that the function from Event Listener cannot return a value. How can I work with this issue? This is a code sample that I using on my AIR app. This code I want to re-use in other situations that I want to parse a directory files. private function initApp():void { try { // Seta o diretoório de molduras var directory = diretorio_mestre.resolvePath

Touch events are wrong for transformed SVG elements

允我心安 提交于 2021-01-29 03:14:20
问题 In the process of experimenting with scaling/panning an inline SVG image by applying a matrix transform I have discovered a rather peculiar thing. After loading the image I am attaching a touchstart event listener to some of the elements in the SVG image and the event fires right away when the object is touched. However, after applying a transform document.getElementById('mysvg').setAttribute('transform''matrix(a b c d e)') which has the effect of scaling and/or translating the entire SVG

How to overwrite addEventListener in Firefox 3.x?

天涯浪子 提交于 2021-01-28 07:28:52
问题 im making a greasemonkey userscript which puts all kinds of shims and polyfills in the page for old browsers. the problem is that none of them seems to include anything to make the third parameter of 'addEventListener' optional, and since webpages usually omit it, it gives a "Not enough arguments." error everywhere. i tried to overwrite it this way: Element.prototype.oldaddEventListener = Element.prototype.addEventListener; Element.prototype.addEventListener = function(event,handler,

addEventListener works in simple for loop but doesn't work with for-in loop

一笑奈何 提交于 2021-01-28 05:40:38
问题 When I use simple for loop, addEventListener works well in for loop. But when I use for-in loop, it makes error like Uncaught TypeError: checklist[i].addEventListener is not a function This is my work-well code. var checklist = document.querySelectorAll(".checklist"); for (var i = 0, len = checklist.length; i < len; i += 1) { checklist[i].addEventListener('change', function (event) { alert('test'); }); } This is my Error code. var checklist = document.querySelectorAll(".checklist"); for (var

JavaScript - addEventListener “click” doesn't work

╄→尐↘猪︶ㄣ 提交于 2021-01-01 08:07:46
问题 I want take a value from input after click on button but all the time function var buttonToBinary = document.querySelector("#toBinary"); buttonToBinary.addEventListener('click', console.log(getInput())); function getInput() { return document.querySelector("#inputSector").value; } <input type="text" name="userInput" id="inputSector" value="aa" /> <button id="toBinary" type="submit">to binary</button> getInput() was started on load page. Please, help me. 回答1: When you do: buttonToBinary

addEventListeners and React not working as planned

对着背影说爱祢 提交于 2021-01-01 06:45:52
问题 I try to make a timeline that is dynamicaly loaded when scrolling. Due to this I need the scroll event, combined with React. window.addEventListener("scroll", console.log('scroll'), true); This should console log a scroll every time I scroll, but it just log it once, then nothing EDIT: If I use it in my real application now, with this code : callbackFunc = () => { for (var i = 0; i < items.length; i++) { if (this.isElementInViewport(items[i])) { items[i].classList.add("in-view"); } } }