Skip to content
Advertisement

Tag: javascript

How to remove an HTML element using Javascript?

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

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

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

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

Advertisement