[Javascript] Changing an Objects ID and Name

Terry Riegel riegel at clearimageonline.com
Wed Sep 6 07:56:00 CDT 2006


Hello,

I would like to swap out an image in an application I am writing.  
Basically I want to swap two image tags, the trick is I want to swap  
their ID and NAME tags also.

For example, I have the following HTML...


  ...
<img src="image1.jpg" width="100" height="200" name="abc" id="abc">
  ...
<img src="image2.jpg" width="120" height="180" name="def" id="def">
  ...


that I would like to use javacscript to make into...

  ...
<img src="image2.jpg" width="120" height="180" name="def" id="def">
  ...
<img src="image1.jpg" width="100" height="200" name="abc" id="abc">
  ...

The important thing Is I would like to swap all of the attributes  
out. i.e. width,height,id,name,src

Thanks,

Terry Riegel



More information about the Javascript mailing list