I am a total newbie. Can somebody tell me how to remove an HTML element using the original Javascript not jQuery. index.html myscripts.js What happens when I click the submit button, is that it will disappear for a very very short time and then appear back immediately. I want to completely remove the element when I click the button. Answer
Tag: javascript
How to replace item in array?
Each item of this array is some number: How to replace some item with a new one? For example, we want to replace 3452 with 1010, how would we do this? Answer Also it is recommend you not use the constructor method to initialize your arrays. Instead, use the literal syntax: You can also use the ~ operator if you
Getting cookies in a google chrome extension [duplicate]
This question already has answers here: How do I return the response from an asynchronous call? (41 answers) Closed 25 days ago. I am trying to get a cookie specifically from a domain using this code: The problem is that the alert always says undefined. However, if I change to it works properly. How do I save the value to
Best way to share constants between Javascript & CSS
I’m creating a website with lots of dynamic stuff laid out in javascript, as well as CSS. What’s bothering me is that half of my dimension constants (positions and sizes of things on the page) are in my javascript, whereas others are in my CSS. Is there a good way to have a “single place” for constants like this? First
How to get all selected values of a multiple select box?
I have a <select> element with the multiple attribute. How can I get this element’s selected values using JavaScript? Here’s what I’m trying: Answer No jQuery: Quick example:
How to make this regex replace work on all characters, not just the first?
I’m trying to replace all spaces within a string with hyphens. I tried this: But it only replaces the first instance of a space and not the ones after it. What is the regex to make it replace all empty spaces? Answer try the g flag is key here. it means global replace, ie replace all
Confirmation delete window – deleting record when click delete or cancel
I have a Javascript file that contains the function for calling the confirmation delete window, the code used is similar to the following: I have a gridview with a template field that can delete a row in the gridview, this is a snippet of what I have: Within the aspx.vb page I have code to do the deletion of the
Create an array with random values
How can I create an array with 40 elements, with random values from 0 to 39 ? Like I tried using solutions from here: http://freewebdesigntutorials.com/javaScriptTutorials/jsArrayObject/randomizeArrayElements.htm but the array I get is very little randomized. It generates a lot of blocks of successive numbers… Answer Here’s a solution that shuffles a list of unique numbers (no repeats, ever). If you want
Do tags only go in the tag?
Is it possible/good practice to use <link href””> to include stylesheets outside of the <head> tag, or do they only work / should they be only used in <head>? Answer It’s possible to do it. It’s not recommended to do it, because whatever content comes before the <link> will start rendering and then when the stylesheet is loaded will be
Prevent scrolling of parent element when inner element scroll position reaches top/bottom?
I have a little “floating tool box” – a div with position:fixed; overflow:auto. Works just fine. But when scrolling inside that box (with the mouse wheel) and reaching the bottom OR top, the parent element “takes over” the “scroll request” : The document behind the tool box scrolls. – Which is annoying and not what the user “asked for”. I’m