SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,658
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Question about Suckerfish IE6 Hover?

    So... the below code makes the input hover in IE6. How do I add a textarea hover to that as well? The only way I found was to copy/paste the code all over again (a duplicate) and put in "textarea" instead of input. But that's double the amount of code - there's got to be a way to combine them right?

    sfHover = function() {
    var sfEls = document.getElementById("content").getElementsByTagName("input");
    for (var i=0; i<sfEls.length; i++) {
    sfEls[i].onmouseover=function() {
    this.className+=" hover";
    }
    sfEls[i].onmouseout=function() {
    this.className=this.className.replace(new RegExp(" hover\\b"), "");
    }
    }
    }
    if (window.attachEvent) window.attachEvent("onload", sfHover);

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ewwatson View Post
    there's got to be a way to combine them right?
    Will Array.concat() work on the NodeList returned by getElementsByTagName()?

    Code:
    var sfEls = document.getElementById("content").getElementsByTagName("input");
    var sfEls2 = document.getElementById("content").getElementsByTagName("textarea");
    sfEls = sfEls.concat(sfEls2);
    sfEls2 = null;

  3. #3
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,658
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Thanks World Wide Weird! However, JS is not my strong suit. Can you possibly show me how that would piece together with the script that I'm currently working with? Then I'll give it a try. Thanks man - appreciate it!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •