events - Javascript OnMouseOver and Out disable/re-enable item problem -
I wanted some radio buttons that were disabled when the mouse was over and was re-enabled when it went out (Just for fun).
& lt; Forms & gt; & Lt; Input type = "radio" name = "rigged" onMouseOver = "this.disabled = true" onMouseOut = "this.disabled = false" & gt; & Lt; / Form & gt; When the mouse moves to it, it does this so that when this button is closed then it is not enabled again. Also, how can I make it default to enable so that when you refresh the page, it will not be inactive.
Thanks in advance.
They do not remove mouseout events because they are disabled.
So you have to wrap it in a div and hold the events of the division.
If you want a clean JavaScript, example of the Feders example "Toggle Diselicated" script should be used.
If you want jQuery and not-so-newbie friendly:
& lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Page & lt; / Title & gt; & Lt; Script src = "jquery-1.3.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Function () {function toggleDisabled (d) {var disable = d; this.disableChildren = function () {$ (this) .children (). Each (function () {this.disabled = d;});} } $ ("Form .radios"). Hover (new toggle disabled (true). Disable child, disabled new toggle (wrong). Disabled child);}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form & gt; & Lt; Div class = "radio" & gt; & Lt; Input type = "radio" name = "rigged" value = "1" /> Item A & lt; Br / & gt; & Lt; Input type = "radio" name = "rigged" value = "2" /> Item two & lt; Br / & gt; & Lt; Input type = "radio" name = "rigged" value = "3" /> Item three & lt; Br / & gt; & Lt; Input type = "radio" name = "rigged" value = "4" /> item four & lt; / Div & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment