Hello fellow coder i am new to web programming and i need so major help please 🙂
well basically what i want is that when a user clicks on a image it changes the text in the inner html. Now I want the text changing done by using javaScript but only using the if statement. What i mean is when we click on the image we can check the id and if we are clicking on the image change the inner text of the html
here is some code that i have managed to do 🙂
<html>
<head>
<title> Welcome to Test </title>
<script language="Javascript">
image1=new Image
image1.src="picture1.jpg"
image2=new Image
image2.src="picture2.jpg"
function Change(){
document.getElementById("lol").innerHtml = "Hello world"
}
</script>
</head>
<body style = " margin: 0px; padding:18px;">
<table align = "center" border = "1" width="500px" >
<tr>
<td colspan="10" > <img src ="Logo.jpg" alt="This is the logo "> </td> <tr/>
<tr> <td colspan="10" > <tr/>
<tr> <td> <td/> <td> <td/> <td> <td/> <td> <td/> <td> <td/> <tr/>
<tr><td> <td/> <td> <td/> <td> <td/> <td> <td/> <td> <td/> <tr/>
<tr> <td> <td/> <td> <td/> <td> <td/> <td> <td/> <td> <td/> <tr/>
</table>
<object width="800" height="600" data="GreatMovie.wmv"></object>
<img src = "buttonUp.jpg" alt =" click me " width = " 200" height ="300" border=0 name = "buttonOne">
<a id="lol" href="#" onClick="Change();" onMouseOver="document.picture.src=image2.src" onMouseOut="document.picture.src=image1.src" > Hello
<img name="picture" src="picture1.jpg" alt="My Image" />
Hello
</a>
</body>
</html>
It is innerHTML not innerHtml.
Here is a JSFIDDLE link: http://jsfiddle.net/ywPfK/