Here I’ve got some trouble trying to add content in a page.
<body>
<div id="wrapper">
<div id="nav">
<ul>
<li><a href="#"><span>exercizeI</span></a></li>
<li><a href="#"><span>exercizeII</span></a></li>
<li><a href="#"><span>........</span></a></li>
<li><a href="#"><span>........</span></a></li>
</ul>
</div>
<div id="content"></div>
</div>
</body>
So I’be tried to use that piece of code and it didn’t work
var table1='<table>..some content..</table>}';
$('#nav li a:eq(1)').click(function (){$('#content').innerHTML='habarlaaaa';});
then tried this one
function press(){
var but = document.getElementById('wrapper').getElementById('nav').getElementsByTagName('ul')[0].getElementsByTagName('li')[1].getElementsByTagName('a')[0];
var table1='<table>..some content..</table>}';
var content = document.getElementById('wrapper').getElementById('content');
but.onclick=function(){content.innerHTML=table1};
};
..and it became even worse by giving me:
Uncaught TypeError: Object # has no method ‘getElementById’
error
Why is this happening?
BR, Stephan
Using jQuery you can use the html() function like this: