A bit of confusion about modifying image addresses using JS

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.