About document.getElementID? Explain giving one example.

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

Answers were Sorted based on User's Feedback



About document.getElementID? Explain giving one example. This was asked by a interviewer when i..

Answer / 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

About document.getElementID? Explain giving one example. This was asked by a interviewer when i..

Answer / kishore.gsgs

using this u can access any html elements by its id.Here we
are going to access <input> textbox by its id("abc").when we
click on
submit button javascript execute and <tr> will not be displayed
<html>
<head>
<script type="text/javascript">

function change()
{
alert("success");
alert(document.getElementById("kishore").value);
}
</script>

</head>
<body>
<input type="text" id="kishore">
<input type="button" name="submit" value="submit"
onClick="change()"/>
</body>
</html>

Is This Answer Correct ?    7 Yes 3 No

Post New Answer

More JavaScript Interview Questions

You have an asp. Net web application running on a web-farm that does not use sticky sessions - so the requests for a session are not guaranteed to be served the same machine. Occasionally, the users get error message validation of view state mac failed. What could be one reason that is causing this error?

0 Answers  


How do you create a new object in JavaScript?

3 Answers   Satyam,


What is Number object in JavaScript?

0 Answers  


Do unused imports affect performance javascript?

0 Answers  


Is client side front end?

0 Answers  






How does typeof operator work?

0 Answers  


What is the best ide for javascript development?

0 Answers  


What is the syntax of ‘self invoking function’? Give an example?

0 Answers  


How to convert a string to a number using javascript?

0 Answers  


what is function of stdio.h

0 Answers   TCS,


Text from your clipboard?

0 Answers  


How to accessing elements using javascript?

0 Answers  


Categories