www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to find all TR with ID=pattern?

  1. #1
    Join Date
    Aug 2005
    Posts
    6

    Question How to find all TR with ID=pattern?

    I need to find all the TR tags in a table where the ID for the TR starts with "CM". Not all the TR's have ID's. I can get the collection of TR tags using x=document.getelementsbytagname('tr'), but how to inspect the ID's of each tag in the collection?

    Obviously a real newbie....

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    var aTR=document.getElementsByTagName('tr');
    for(var i=0; i<aTR.length; i++) {
        if(aTR[i].id.match(/^(cm)/i)) {
        	alert(aTR[i].id);
            }
        }
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles