Javascript to change li tag text
I am using the following HTML:
<li id="item1" data="icon: 'base.gif', url: 'page.htm', target: 'Page'">Item 1 Title</li> I am trying to change the Item 1 Title part to something else.
I tried using:
document.getElementById("item1").innerHTML = "Item was changed"; but no luck. Even tried to use:
document.getElementById("item1").value = "Item was changed"; but still no luck.
I just want to change the text and leave it all the same.
Am I doing something wrong?
try it
window.onload = function(){ document.getElementById("item1").innerHTML = "Item was changed"; } you can make a function and all of it after loading the page
var changeText = function(text){ document.getElementById("item1").innerHTML = text; } window.onload = function() { changeText(' some text '); }