Using the dragenter event I show a dropzone on the webpage to have dropped files upload quickly, and it all works well. However, the dropzone also pops up when dragging selected text. How to tell the difference early on? I know that the drop event exposes all file contents to be iterated using dataTransfer.files, but that’s too late. I need
Tag: javascript
Max characters in textarea with jquery
I have the following code, and I’m kind of stuck on what to do next. The idea is when you enter text into a text area a counter tells you how many characters you have left. Once you get to the max characters I want to stop allowing characters to be entered, or delete all the characters that were entered
Is it possible to change the value of the function parameter?
I have one function with two parameters, for example function (a,b). I want to within the function, take the value of b, and replace that with c. I was thinking of something like $(b).replaceWith(c), but it didn’t work out. I know I can create a new variable within the function with the new value, but is it possible to change
Using the jQuery each() function to loop through classname elements
I am trying to use jQuery to loop through a list of elements that have the same classname & extract their values. I have this.. I was reading up on the each() function though got confused how to use it properly in this instance. Answer and if you wanted to get its index in the collection: Reference: .each() and .val()
How to run a function in JavaScript every time a variable changes?
Is there a way in JavaScript to have something like an event that listens to changes in a variable? so when its value is modified the event triggers and then I can call a function. To put this more into context I have a function which handles the html rendering of an array of objects, and I want that function
Architecture query.. Building a service/message bus with Node.js
So the situation is that I have a variety of datasources that are providing a stream of messages from external devices.. some are sending messages on a serial port, some via UDP, some via Telnet.. I wish to build a small Node.js system that receives messages from each of these sources. Around 20 sources all up. I have a variety
Table Row’s OnClick Event is Propagated to all Contained Elements?
I’ve run into some interesting code in our legacy application running under Internet Explorer. Consider the following: So, here’s where I’m stumped. When the user selects an item from the SELECT element, the ONCLICK event is firing, and the following are true: this evaluates to Window Window.event.srcElement evaluates to an array of ‘OPTION’ elements There doesn’t seem to be a
What is the hash tag used for in JavaScript?
I’m not talking about in the URL. I know what that does. I’m talking about how it’s used in actual code. After trying to assign it as a variable, I realized that it’s reserved, but I don’t know what for. Answer Javascript, or more precisely ECMAscript, is an evolving language. Some symbols and keywords (such as “class”) have been reserved
How to get first and last day of the current week in JavaScript
I have today = new Date(); object. I need to get first and last day of the current week. I need both variants for Sunday and Monday as a start and end day of the week. I am little bit confuse now with a code. Can your help me? Answer This works for firstday = sunday of this week and
How to detect if multiple keys are pressed at once using JavaScript?
I’m trying to develop a JavaScript game engine and I’ve came across this problem: When I press SPACE the character jumps. When I press → the character moves right. The problem is that when I’m pressing right and then press space, the character jumps and then stops moving. I use the keydown function to get the key pressed. How can