View Full Version : Variable in innerHTML?
Anicho
01-26-2008, 05:17 AM
var somevar = 'content';
document.getElementsByTagName('a')[a].innerHTML = ''+ somevar +'';
Won't work in javascript am I doing it wrong
coothead
01-26-2008, 06:18 AM
Hi there Anicho,
try it like this...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
window.onload=function() {
var somevar='content';
document.getElementsByTagName('a')[0].innerHTML=somevar;
}
</script>
</head>
<body>
<div>
<a href="#"></a>
</div>
</body>
</html>
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.