Notes for dynamic conversion of IMG. SRC

Source: Internet
Author: User
I have just written something in the past two days and need to dynamically convert the SRC of IMG. I take it for granted: If (IMG. src = '1.jpg ') IMG. the result of src = '2.jpg 'cannot be changed. The IMG can be found only when alert is used. SRC has a path, so IMG cannot be used. src = '1.jpg. So how to judge? Use string. indexof, because IMG. SRC is a string containing the path. We only need to find whether there is an image file name in this path. However, we need to make sure that the file name is case-insensitive before being determined.
Later I changed it to If (IMG. SRC. indexof ('1.jpg ')! =-1) IMG. src = '2.jpg.

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.