Skip to content

Author: admin@master

Get innerWidth() equivalent without jQuery

I’m currently working on eliminating jQuery from some code that I’ve written, and I’ve got a portion of code in which I was computing both the inner and outer widths of some span elements. It seems like .getBoundingClientRect() works fine for getting the outer width of an element, but I&#821…

Loop to remove an element in array with multiple occurrences

I want to remove an element in an array with multiple occurrences with a function. This loop doesn’t remove the element when it repeats twice in sequence, only removes one of them. Why? Answer You have a built in function called filter that filters an array based on a predicate (a condition). It doesn&#…

Onclick event on list item

I’m trying to follow this answer, but rather than using a button as he does in his jsfiddle, I’m trying to use list items: http://jsfiddle.net/hqvDT/108/ It looks like it should work, but when I try to select some text and then press B (for bold), it doesn’t actually bold the text. What&#821…

Div Square, width size based on 100% height

I’m trying to make a responsive square with the width size based on the (100%) height of the element. I believe it’s impossible using only CSS. The square width should be equal to the height (100% of the large container. The large container is more than 100% of the screen). The ratio has to be wid…

Why scroll to top not working when I use jQuery?

I have a popup that is dynamically loading content and using overflow: auto to maintain the popup size and in turn make it scrollable. I have a link at the bottom currently using anchors to scroll to the top of the div. Unfortunately it is also forcing the page to scroll down to that point as well as scroll t…