Example : Updating Text Based on User Input:
Note:
If we want to access the text within a non-input HTML element, then we are going to have to use the innerHTML property instead of value.
<script type="text/javascript">
function changeText()
{
// Get user I/p data
var userInput = document.getElementById (“userInput”).value;
// Get data from non-input element & replace old data
document.getElementById (“boldStuff2”).innerHTML = userInput;
}
</script>
Welcome to the site <b id=“boldStuff2”>dude</b> </p>
<input type=“text” id=“userInput” value=“Enter Text Here” />
<input type=“button” onclick=“changeText ()” value=“Change Text” />
Buy Electronics
Saturday, June 26, 2010
Diff getElementById ().value & getElementById ().innerHTML
Posted by
Arun SP
at
6:25 AM
Labels: Interview Questions 0 comments
Subscribe to:
Posts (Atom)
Mobiles
MP3 Clips
Search...
Blog Archive
Labels
- Csharp (3)
- Design Patterns (2)
- Dot Net (6)
- games (2)
- General (3)
- Interview Questions (9)
- learn new stuff (2)
- SQL (1)
- WCF (1)