Skip to content
Advertisement

javascript enable input on double click

I have a form with some inputs disabled. I want these inputs to be enabled when double clicked. Unfortunately, JS events seem not to fire on disabled inputs. Is there a way around this limitation? Or am I just going to have to wrap any affected input in a span to house the event? http://jsfiddle.net/vhktx/ Answer ondblclick does not get

Return index of greatest value in an array

I have this: What’s the best way to return the index of the highest value into another variable? Answer This is probably the best way, since it’s reliable and works on old browsers: There’s also this one-liner: It performs twice as many comparisons as necessary and will throw a RangeError on large arrays, though. I’d stick to the function.

Why don’t audio and video events bubble?

I was wondering why some Javascript of mine would not work until I figured that the audio events did not bubble up the DOM tree, e.g. the timeupdate-event. Is there a rationale for not letting the events of the audio- and video-tag bubble? Answer The reason why event bubbling exists is solve the ambiguous question of which element is the

Get selection from Google Docs

Is there a way around the fact that does not seem to work in Google Docs? I want to capture text from a highlighted selection from Google Docs. My implementation is with Chrome Extensions, but that is not as relevant as the fact that window.getSelection() doesn’t seem to work there (though it does elsewhere). Thanks! Answer As mentioned on Docs

Global variable in Web worker

I am using this Web worker which has a Global variable declared in it. Can I access the same (Global variable in worker 1) in the newly spawned web worker(worker 2)? When I’ve tried using jQuery in web worker, I get error “window is not defined”. Is there any way to use jQuery in a Web Worker? Answer Web Workers

Extract substring by utf-8 byte positions

I have a string and start and length with which to extract a substring. Both positions (start and length) are based on the byte offsets in the original UTF8 string. However, there is a problem: The start and length are in bytes, so I cannot use “substring”. The UTF8 string contains several multi-byte characters. Is there a hyper-efficient way of

Disable href with jquery/js

I am having difficulties in disabling href links through jquery. I am using this method I modified. Can some please advise or help me in figuring this out? Thank you. jquery/js html Answer You can use preventDefault(); to disable the default behaviour of links (which is, to navigate to the given href).

slideDown jumps abruptly at the end

I’ve built a fairly normal menu-submenu arrangement in a vertical column — nested ULs, using slideToggle to expand and collapse submenus. The problem I’m trying to solve is in the way the submenus “jump” open at the very end. (I’m testing in the latest release of Chrome.) It’s probably most noticeable in the second submenu, “Benefits”. It doesn’t jump when

Advertisement