Today, I encountered a problem when I switched Images Using Js.
< Script >
Function Show (ID)
{
VaR O = This . Document. getelementbyid ('line' + ID );
VaR T = This . Document. getelementbyid (' Switch ' + ID );
// VaR IMG = new image ();
// The initial code does not have a new image object.
VaR IMG = This . Document. getelementbyid ('img' + ID );
If (O. style. Display = 'None ')
{< br> O. style. display = '';
T. innertext = 'consize ';
IMG. SRC = ' / images / page / webshop / 001 / 48_2.gif ';
}
Else
{< br> O. style. display = 'none ';
T. innertext = 'expand ';
IMG. SRC = ' / images / page / webshop / 001 / 48 . GIF ';
}
}
</ Script >
InitialCodeThere is no new image object (note that the first letter of the image is capitalized here), and the result image is always blank. I thought about the cause.
After the code is modified, it is displayed normally. However, there is still a bit of confusion: Sometimes the image is not displayed, and it may take a while,
This is strange!