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

What is a currying function?

494


Explain the difference between call() and apply()?

510


What is noscript tag?

526


How would you compare two objects in JavaScript?

558


What is called variable typing in javascript?

526






How many types of data types are there?

452


What is foreach loop in javascript?

528


What is array in javascript?

483


How do I turn off javascript in chrome?

468


What is the difference between the operators ‘==‘ & ‘===‘?

485


What is js injection?

489


How can you identify a function?

461


What is 'use strict'?

519


What is the difference between scripting and programming?

467


Where do I put javascript code in html?

513