<html>
<head>
<script>
function content(){
alert (this.innerHTML);
}
</script>
</head>
<body>
<div onclick='content(this)'>some text here</div>
</body>
</html>
i get UNDEFINED when i click on the div ..
<html>
<head>
<script>
function content(){
alert (this.innerHTML);
}
</script>
</head>
<body>
<div onclick='content(this)'>some text here</div>
</body>
</html>
i get UNDEFINED when i click on the div ..
You give your div an id
Then need to feed your form with the id
<head>
<script>
function myFunction(mydiv)
{
alert(document.getElementById(mydiv).innerHTML);
}
</script>
</head>
<body>
<div id="mindiv" onclick="myFunction(this.id)">Click me</div>
</body>
Then need to feed your form with the id
Then you need to call the function with the id
Your need to write the function with an argument !
An other solution consist to call the arguments array (here arguments[0]) in the function.Code:<html>
<head>
<script>
function content(that){
alert (that.innerHTML);
}
</script>
</head>
<body>
<div onclick='content(this)'>some text here</div>
</body>
</html>
function alertD(div){
alert(div.innerHTML);
}
<div onclick="alertD(this);">Blablablablab</div>