Date: 02/28/08 (Javascript Community) Keywords: java, seo I'm having trouble dynamically adding events to elements in Internet Explorer 6.0. document.getElementsByClassName = function(cl) { var retnode = []; var myclass = new RegExp('\\b'+cl+'\\b'); var elem = this.getElementsByTagName('*'); for (var i = 0; i < elem.length; i++) { var classes = elem[i].className; if (myclass.test(classes)) retnode.push(elem[i]); } return retnode; } function show_date() { this.childNodes[1].style.display = "inline"; } function hide_date() { this.childNodes[1].style.display = "none"; } function add_function() { var grid = document.getElementsByClassName('date'); for (var i = 0; i < grid.length; i++) { if (window.addEventListener) { grid[i].addEventListener("mouseover",show_date, false); grid[i].addEventListener("mouseout",hide_date, false); } else { grid[i].attachEvent("mouseover",show_date, false); grid[i].attachEvent("mouseout",hide_date, false); } } } Any thoughts? Source: http://community.livejournal.com/javascript/150958.html
|