About document.getElementID? Explain giving one example.

This was asked by a interviewer when i said that i know
some JavaScript.

Answer Posted / negi

using this u can access any html elements by its id.Here we
are going to access <tr> by its id("abc").when we click on
submit button javascript execute and <tr> will not be displayed.
<html>
<head>
<title>xxx</title>
<script language="javascript" type="text/javascript">
function change()
{
document.getElementById("abc").style='none';
return true;
}
</script>
</head>
<body>
<table>
<tr id="abc">
<td>you are great</td>
<td><input type="submit" name="submit" value=""
onClick="return change();"/></td>
</tr>
</table>
</body>
</html>

Is This Answer Correct ?    17 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

java pgme for class members hours:minutes:seconds then the constructor expects milliseconds as assignment and initialize data members the members function print hh:mm:ss 90,000 milliseconds passed in constructor then the output is 00:01:30

1582


Does html5 replace javascript?

606


Explain unescape() in javascript?

582


what is function of stdio.h

2139


What is difference between java and javascript?

585






What is the use of javascript?

604


what is a dataset

1675


Can I open javascript on iphone?

577


How to write normal text code using JavaScript dynamically?

576


What is the difference between the substr() and substring() functions in javascript?

573


What is enum size?

548


How generic objects can be created?

552


What is the difference between HTMLCollection and NodeList?

615


What are the uses of javascript in web page designing?

546


Should I learn java first or javascript?

585