<input id="txtShoolName" type="text" style="width: 150px;" class="input" />
<select name="DropDegree" id="DropDegree" class="input" style="width: 150px;">
</select>
.....很多个HTML1.等不同的HTML,我现在能得到<input id="txtShoolName" type="text" style="width: 150px;" class="input" />或<select name="DropDegree" id="DropDegree" class="input" style="width: 150px;">
</select>的HTML
2.每个控件的HTML的ID是不一样的!所以这个ID要动态的提取
要求把id对应的加上一个i变量,这个i我已定
如:
<input id="txtShoolName2" type="text" style="width: 150px;" class="input" />
<select name="DropDegree2" id="DropDegree" class="input" style="width: 150px;">
</select>

解决方案 »

  1.   

    我现在是这样打算的!可后面不知道咋写
    var str='<select name="DropDegree" id="DropDegree" class="input" style="width: 150px;">
    </select>';
    str=str.replace(/id=[\w]*/,***i);
    ***这个地方不知道咋写
      

  2.   

    str=str.replace(/id=[\w]*/,'id="' + i + '"'); 
      

  3.   

    in C#
    {Regex reg = new Regex("(/id=[\w]*/");str = Regex.Replace(str, MatchE);
    }        public string MatchE(Match mat)
            {
                return mat.Groups[1].Value + 数字;
            }
      

  4.   

    是C#版,但这个地方想用js来实现!