Sorry in advance for my ignorance, but I just started javascript today.
I wrote a little script with a condition. If the condition is true the stuff inside a <p> element should be altered, but For some reason I can't see how to do this I looked up for the DOM, but i didn't find <p> in there.
If someone maybe has an idea on how to achieve this (or maybe a nice alternative)please let me know, All tips and hints are welcome.
- Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>JAVA SCRIPT TEST PAGE</title>
<script type="text/javascript">
function my_first_function(){
var text1 = 'monkeys';
if (document.getElementById(input)!= text1){
document.write(document.getElementById(p_element)='wrong text');
}else{
document.write(document.getElementById(p_element)='your correct');
}
}
</script>
</head>
<body>
<input type="text" size="30" id="input" onchange="my_first_function()" value="" />
<br />
<p id="p_element">This is just default text.</p>
</body>
</html>
btw, I wasn't sure if this was the right thing to get the element by ID


