views:

197

answers:

2

Hey,

Im looking how to have hover effects on input boxes in Internet Explorer 6? Im using YUI if I can utilise that.

Thanks

A: 

Try this javascript:

var inputs = document.getElementsByTagName("input");
var hoverOn = function() {
    this.className = "hover";
};
var hoverOff = function() {
    this.className = "";
};
for (var i = 0, l = inputs.length; i < l; ++i) {
    inputs[i].onmouseover = hoverOn; 
    inputs[i].onmouseout = hoverOff;
}

And the CSS:

input.hover {
    background-color: #f0f;
}

Here's the above, which works in Firefox... let me know how IE6 goes... http://jsbin.com/aseli

nickf
scunliffe
yep probably... that can be an exercise for the reader though..
nickf
A: 

HTML:

<input type="text" id="elementid" />

JS:

var oElement = document.getElementById("elementid"); 
function fnCallback(e) { alert("mouse over"); } 
YAHOO.util.Event.addListener(oElement, "mouseover", fnCallback);

Taken from http://developer.yahoo.com/yui/event/#start

powtac
you're going to add an id to every input element?
nickf
No it is not required! You just must tell Javascript which of the input fields is your target. Post your input field and we will find a better selector.
powtac
Hi that is perfect. Ive coupled it with YAHOO.util.Selector.query to obtain specific classes. However I have hit another wall. Most content is Ajax. So when the selector is run it only picks up whats in the container. Am I going to have to run YAHOO.util.Selector.query('classname') on every page?
jugger000