quote:
Originally posted by glennlopez
<head>
<script language="Javascript">
var element = document.getElementById("poop");
element.innerHTML = element.innerHTML.substr(0,4);
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div id="poop">hello world</div>
</body>
That won't work because the div is created after the script is called. So you need to place the code in after the div like this:
code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div id="poop">hello world</div>
<script language="javascript">
var element = document.getElementById("poop");
element.innerHTML = element.innerHTML.substr(0,4);
</script>
</body>
</html>
Tested it on my local server and it worked