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?
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?
Share Improve this question asked Sep 12, 2012 at 4:41 AaronAaron 3,64913 gold badges36 silver badges49 bronze badges 6 | Show 1 more comment2 Answers
Reset to default 14try this
window.onload = function(){
document.getElementById("item1").innerHTML = "Item was changed";
}
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 ');
}
innerHTML
should work just fine jsbin.com/abaxuw/1/edit – elclanrs Commented Sep 12, 2012 at 4:44