SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Setting all same-name-tag property in one go

    Hi

    If I need to have all <input type="text"/>'s border in a specific table to red, all I got to do is
    Code:
    #table1 input[type="text"]
     {
            border:1px solid red;
     }
    Is there a Javascript equivalent ?
    Code:
    document.getElementById("table1").getElementsByTagName('input')[0].style.borderColor = 'blue';
    .
    .
    .
    document.getElementById("table1").getElementsByTagName('input')[25].style.borderColor = 'blue';
    to
    Code:
    document.getElementById("table1").getElementsByTagName('input')[all].style.borderColor = 'blue';
    Thanx
    Anjanesh

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not like that there isn't. You can use JavaScript to create a new stylesheet with that rule though. http://www.quirksmode.org/dom/changess.html
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    #table1 input[type="text"],#table1 input.jsclass{border:1px solid red;}
    
    function jscls(){
    var where=document.getElementById('table1');
    var what=where.getElementsByTagName('INPUT');
    for(var i=0;i<what.length;i++){
    if(what[i].type=='text'){
    what[i].className='jsclass';
    }
    }
    }
    window.onload=jscls


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
  •