Reputation: 3639
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 have tried using:
document.getElementById("item1").innerHTML = "Item was changed";
but had no luck. Even tried using:
document.getElementById("item1").value = "Item was changed";
but still no luck.
I am only wanting to change the text and leave eveything else the same.
Am I doing something wrong?
Upvotes: 10
Views: 45670
Reputation: 633
you can make a function and all it after the page is loaded
var changeText = function(text){
document.getElementById("item1").innerHTML = text;
}
window.onload = function() {
changeText(' some text ');
}
Upvotes: 0
Reputation: 3274
try this
window.onload = function(){
document.getElementById("item1").innerHTML = "Item was changed";
}
Upvotes: 14