开发者

and [object HTMLInputElement] javascript

This code written as it is in a simple page generates an [object] as I needed.

function jsFunction(){
 var arr=document.all("camp");
 alert(arr);
}

HTML:

<开发者_JS百科;input name="ctl00$MainContent$_basicDataControl$_winProbabilityPopUpControl$_winProbabilityControl$_groupWinProbabilityQuestions$ctl00$_groupPercentage" type="text" id="camp" class="readonly2" readonly="readonly"/>
<input name="ctl00$MainContent$_basicDataControl$_winProbabilityPopUpControl$_winProbabilityControl$_groupWinProbabilityQuestions$ctl01$_groupPercentage" type="text" id="camp" class="readonly2" readonly="readonly"/>
<input type="button" value="apasa aici!" onClick="jsFunction()">

In another page this code written with others inputs and included in a form returns an [object HTMLInputElement] and I can't parse the array. What could be the problem?


as specified in my comment above, an id must be unique in page. so you should retrieve a collection of input instead (e.g. document.getElementsByTagName('input') and exclude last element (is the submit))

or in jQuery $('input[type=text]')

obviously you need to call that function after the elements are created

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜