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

How do I activate javascript on my phone?

0 Answers  


What is the use of a boolean object in javascript?

0 Answers  


How long does it take to get good at javascript?

0 Answers  


What is negative infinity?

2 Answers   CoKinetic, Satyam,


What is the role of javascript in html?

0 Answers  






How many types of functions are there in javascript?

0 Answers  


What are the datatypes in javascript?

0 Answers  


What is the Difference between HTML and DHTML

15 Answers   TCS,


What is 'use strict'?

0 Answers  


Is javascript hard to learn?

0 Answers  


How to create 3-dimensional Array in Javascript?

3 Answers   CybAge, Shapia,


What is a “closure” in JavaScript? Provide an example

1 Answers  


Categories