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
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 |
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 |
How to hide javascript code from old browsers that dont run it?
What are undefined and undeclared variables?
What is the disadvantage of using innerhtml in javascript?
Explain how to read and write a file using javascript?
Are java and javascript the same?
What are the different ways to create an array in javascript?
What is nodetype in javascript?
What is the use of a set object in javascript?
What Does JavaScript Void(0) Mean?
show the date in textbox when we select item (items like-- today,yesterday,lastweek,lastmonth,lastyear) from dropdownlist using javascript?
What are the problems associated with using javascript, and are there javascript techniques that you discourage?
How do you change the style/class on any element using javascript?