I want to make something like navigation bar that can move whole element, without allowing dragging anywhere on the parent entire element to control the dragging. For example: Dragging on a title bar drags the whole window that it is contained within, but dragging elsewhere on the window container does not dr…
Tag: javascript
What is the difference between “window.location.href” and “window.location.hash”?
I learned “window.location.hash” new and tried in my jquery code instead of “window.location.href” and both of them gave same results. Code is here : What is the difference between them? Answer For a URL like http://[www.example.com]:80/search?q=devmo#test hash – returns the part…
Changing button text onclick
When I click on myButton1 button, I want the value to change to Close Curtain from Open Curtain.HTML: Javascript: The button is displaying open curtain right now and I want it to change to close curtain, is this correct? Answer If I’ve understood your question correctly, you want to toggle between ̵…
jQuery: Select data attributes that aren’t empty?
I’m trying to select all elements that have a data-go-to attribute that is not empty. I’ve tried $(‘[data-go-to!=””]’) but oddly enough it seems to be selecting every single element on the page if I do that. Answer try UPDATE: For the sake of not leading anyone astray, this…
How to parse a date in format “YYYYmmdd” in JavaScript?
This is a noob question: How to parse a date in format “YYYYmmdd” without external libraries ? If the input string is not in this format I would like to get invalid Date (or undefined if it will be easier). Answer Usage: UPDATE: As Rocket said, months are 0-based in js…use this if month̵…
Javascript to Grab the Selected Value from a list of Form Radio Options OR text field, whichever is used, and output to text?
I’m new to Stack and this is my first question, but I did search and wasn’t able to find anything that was specifically what I am trying to accomplish. I’m all for learning, so any reference material that would help me better understand how to approach this would be appreciated, but if someo…
How do I measure the execution time of JavaScript code with callbacks?
I have a piece of JavaScript code that I am executing using the node.js interpreter. How can I measure the time taken by these database insert operations? I could compute the difference of date values after and before this piece of code but that would be incorrect because of the asynchronous nature of the cod…
How to access the parentNode of a selection to raise an element?
I’ve created the following document: When I mouse over each path I want to append it last inside the svg:g so it appears on top of the other lines, but I don’t know how to properly select the parentNode: p1 works, but I wanted to make sure that this is a .line, so I preferred to use current_gene_p…
How to add listener for a custom event in the DOM?
What I want is to create my own function that will be bound as an event listener similar to how other event listeners (e.g., onclick) are set: Is it possible and if so how? Answer The problem you have is the browser does not realize it is a function in there. It is a string, the only way you can
How do I get the current time only in JavaScript
How can I get the current time in JavaScript and use it in a timepicker? I tried var x = Date() and got: Tue May 15 2012 05:45:40 GMT-0500 But I need only current time, for example, 05:45 How can I assign this to a variable? Answer or