Skip to content
Advertisement

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’m a bit stuck on getting the inner width. (i.e. the

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’t alter the original array but returns

Using `this` for Parent Function inside a Nested Function

In the Apple “classs”, how can the nested function countSeeds() retrieve the value this.price? jsfiddle: http://jsfiddle.net/VGqEa/ Output Answer put var self = this at the top of Apple, and then refer to this as self instead in the nested function. i.e.: You could also put the self=this statement at the beginning of this.cutOpen, since this will still refer to the

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’s wrong? HTML: CSS: JS: Answer The problem is

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 width=height to keep the square.

Concrete JavaScript regular expression for accented characters (diacritics)

I’ve looked on Stack Overflow (replacing characters.. eh, how JavaScript doesn’t follow the Unicode standard concerning RegExp, etc.) and haven’t really found a concrete answer to the question “How can JavaScript match accented characters (those with diacritical marks)?” I’m forcing a field in a UI to match the format: last_name, first_name (last [comma space] first), and I want to provide

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 to

Advertisement