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

What is the use of javascript?

0 Answers  


How to create scale in P info

0 Answers   MAHINDRA,


What is javascript used for on iphone?

0 Answers  


When do we use JSON.stringify()?

0 Answers  


Write a main method that prompts the user to enter the starting population, birth and death rates, and the number of years. The input birth and death rates cannot be negative, the starting population cannot be less than 2, and the number of years greater than 0. If the user enters an invalid value, this program will prompt user to re-enter the value until a valid value has been read. When all input values are valid, call on the methods above to compute estimated population and print result.

0 Answers   Wipro,






Why is javascript so hard?

0 Answers  


How we can add title of the page by javascript?

0 Answers  


if the two text boxes are there i want assign the vales like 2&3 and if i select button means i want find the sum.this is client side scripting in javascript

7 Answers   Infosys,


What is the output of below code var car = new Vehicle("Honda", "white", "2010", "UK"); console.log(car); function Vehicle(model, color, year, country) { this.model = model; this.color = color; this.year = year; this.country = country; }

1 Answers  


Which companies are using node js?

0 Answers  


How do I turn on javascript in google chrome?

0 Answers  


What is foreach loop in javascript?

0 Answers  


Categories