SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS and Javascript Regex/Replace

    Hi all - a regex newbie here:

    I have a little Ajax script and I'm trying to remove some CSS elements from a DIV tag and I'm have a bit of trouble with the Regex. Right now I'm trying to remove the z-index attribute. It can look something like any of these:

    z-index: 1000;
    z-index: 0;
    z-index: 75;
    etc...

    Here's what I'm using right now:

    Code:
    document.getElementById('right_column').innerHTML.replace(/z-index: [0-9]; /gi, "replaced"));
    It replaces z-index: 0; just fine but I can't find the correct modifiers to make it work for 2, 3 or 4 digit z-indexes. Any ideas would be much appreciated. Thanks!

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is this mania for innerHTML?

    document.getElementById('right_column').style.zIndex='';

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Denver
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe something like this?

    Code:
    document.getElementById('right_column').innerHTML.replace(/z-index: (\d+); /gi, "");


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
  •