Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display problem

 
som bhardwaj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m using this code & trying to display "Showing List" using x.value = "Showing List"; but its not displaying. please suggest me how will it work?
<html>
<head>

<script>
function funct()
{
alert("calling");
//document.write("Listing");
var x=document.createElement('li');
x.value = "Showing List";
x.text = "Showing list"
var y = document.getElementById('A1');

try {
y.add(x, null); // standards compliant; doesn't work in IE
}
catch(ex) {
y.add(x); // IE only
}
}
</script>

</head>

<body >
<ul id= 'A1'>String<script>funct();</script>
<li>


</li>
</ul>
</body>

</html>



 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
li elements do not have text and value properties. You can set the attributes, but they are not going to do anything. If you want to add text to an li, you wither need to add a textNode or you have to use innerHTML.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic