SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    sydney
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dom scripts + regexp

    What this script is doing is creating a list of anchors that put the focus back on the input element of the form element that is not valid. What I don't understand is what this [1] part of the script is referring to:

    newa.appendChild(document.createTextNode(txt));
    newa.href='#'+f.id;
    newa.onclick=function()
    {
    var loc=this.href.match(/#(\w.+)/)[1];
    document.getElementById(loc).focus();
    return false;
    }

    Thanks in advance for any help on this.

  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)
    match() returns an array. That's selecting the second element in the array, which is the contents of the parenthesized subexpression.
    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 Member
    Join Date
    Dec 2004
    Location
    sydney
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Kravvitz. I probably should have worked that one out for myself . Makes sense now.


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
  •