How can JavaScript change CSS :hover properties? For example: HTML CSS How can the td :hover properties be modified to, say, background:#00ff00, with JavaScript? I know I could access the style background property using JavaScript with: But I don’t know of a .style JavaScript equivalent for :hover. Answer Pseudo classes like :hover never refer to an element, but to any
Tag: html
How to get text of an input text box during onKeyPress?
I am trying to get the text in a text box as the user types in it (jsfiddle playground): The code runs without errors, except that the value of the input text box, during onKeyPress is always the value before the change: Question: How do I get the text of a text box during onKeyPress? Bonus Chatter There are
Does HTML5 localStorage maximum size include key names?
HTML5’s localStorage WebStorage has a maximum size of 5MB. Does this include the key names? For instance, if I were to use key names “quite-a-long-key-name-and-this-is-only-1” instead of “key1”, would I run out of space sooner? On a slightly related topic; is there any de-facto convention for naming localStorage keys? How are namespace collisions prevented when using third party JS scripts?
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
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
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
How can I run a Greasemonkey script when page changed via ajax?
I have that script: It works fine but it works only main page load. I want to run this when page changed via ajax. How can I do that? Also please give examples with your answers. I’m newbie. I don’t know how to use things in your answers. Answer Since browser’s environment is event-driven you’ll have to either set up
Set IFrame allowfullscreen with javascript
I tried to set allowfullscreen attribute to the iframe, but it doesn’t work: I checked it with chrome -> inspect element, but the iframe has no allowfullscreen attribute, after this code. Thanks in advance, Answer iframe.setAttribute(‘allowFullScreen’, ”)
Open link in new window or focus to it if already open
I have a link which should open in a new tab, but if the tab is already open, just switch to it. I’ve tried with javascript, wnd = window.open() and than wnd.focus(), that works in Chrome 19, but not in FF 13 or IE 9. Here’s the code I’ve written : Any idea how can I open or switch to
Why does my http://localhost CORS origin not work?
I am stuck with this CORS problem, even though I set the server (nginx/node.js) with the appropriate headers. I can see in Chrome Network pane -> Response Headers: which should do the trick. Here’s the code that I now use to test: I get XMLHttpRequest cannot load http://stackoverflow.com/. Origin http://localhost is not allowed by Access-Control-Allow-Origin. I suspect it’s a problem