2010-03-16 3 views
1

JavaScript에서 개체를 만들고 HTML의 ID로 가리키는 정보를 온라인으로 찾는 데 문제가 있습니다. 여기 "id"가있는 테이블 행을 가리키는 javascript의 개체 만들기

내가 지금까지 자바 스크립트가 무엇 :

function countRecords() 
{ 
headRow=new Object(); 
//point to specific id here? 
var rowCount = 0; 

html로 : 책이 정말 무엇을 의미하는지 "객체를 생성"라고

<table id="prodTable"> 
<tr><th colspan="8">Digital Cameras</th></tr> 
<tr id="titleRow"> 
    <th>Model</th> 
    <th>Manufacturer</th> 
    <th>Resolution</th> 
    <th>Zoom</th> 
    <th>Media</th> 
    <th>Video</th> 
    <th>Microphone</th> 
</tr> 

답변

0

는 "변수 headRow를 선언 ID "titleRow"인 문서 객체에 대한 참조를 얻습니다.

var headRow; // create the "object" 
headRow = document.GetElementById('titleRow'); // point to the table row "titleRow" 
+0

그래서, 그들은 그것을 그렇게 표현 된 것 바랬다. 감사! – Matt

+2

자바 스크립트는 대소 문자를 구분합니다. 'document.GetElementById'는 함수가 아니지만'document.getElementById'는 –

+0

입니다. 저는 그것에 대해 재미있어 보이는 것을 알고있었습니다. 오늘 간격 : p – lincolnk

관련 문제