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

How do you name a variable in javascript?

453


How do you declare in javascript?

448


How to have the status line update when the mouse goes over a link (the support of the status line is sporadic)?

460


What is event bubbling in the dom?

537


What is the difference between undefined and not defined in JavaScript?

500






Explain closures in javascript?

468


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

478


List some design patterns in javascript?

452


Is javascript whitespace sensitive?

472


How do you add an element at the end of an array?

528


What can I build with javascript?

480


Give an example of closure?

509


How can the style/class of an element be changed?

532


How many types of functions are there in javascript?

430


Basic methods for opening a popup window using javascript?

486