Jump to content

Javascript Can't Change An Ajax Element?


therschbach

Recommended Posts

I hope I can explain my problem without it being too confusing.I have my index page pointing to an external javascript file. Two of these functions flip a picture back and forth when a mouse hovers over & off of the picture. I know for certain the function works. Here is the image html...

<img class="left" src="http://i20.photobucket.com/albums/b202/therschbach/050908washobverse.jpg" onMouseOver="reverse(this)" onMouseOut="obverse(this)">

The javascript...

function reverse(image){  var address = (image.src);  address = address.replace(/obverse/,"reverse");  image.src = address;}function obverse(image){  var address = (image.src);  address = address.replace(/reverse/,"obverse");  image.src = address;}

The problem arises when I try to use the onMouseOver and onMouseOut handlers inside of a txt file that is brought in by AJAX. If I paste the <img> code inside of my index.php, the js works and the picture flips. If I paste the <img> code inside of my txt file to be inserted into the index.php page via AJAX (when a menu button is clicked), the onMouseOver and onMouseOut give me a javascript error: "Line 25: Object Expected". I think this is referring to line 25 of the .txt file because that is the line right before the <img> code. Does anyone see what I'm doing wrong?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...