JavaScript learning: Photo Gallery

Source: Internet
Author: User

Html:

1 <H1>Snapshots</H1>2 <ul>3     <Li><ahref= "images/1.jpg"onclick= "show (this); return false;"title= "one" >First picture</a></Li>4     <Li><ahref= "images/2.jpg"onclick= "show (this); return false;"title= "both" >Second picture</a></Li>5     <Li><ahref= "images/3.jpg"onclick= "show (this); return false;"title= "three" >The third picture</a></Li>6     <Li><ahref= "images/4.jpg"onclick= "show (this); return false;"title= "four" >Picture Four</a></Li>7 </ul>8     <!--the onclick event function is triggered and returns false so the link is not opened -9     <ahref= "http://www.baidu.com"onclick= "return false">Click Me to Baidu</a>Ten <imgID= "pla"src= "images/6.jpg"/alt= "picture library">

Javascript:

1<script type= "text/javascript" >2         /*3 name This function showpic, and give the function a parameter named Whichpic4 get the position of the PLA and assign it to the variable placeholder5 use the SetAttribute method to refresh the SRC attribute of the placeholder element6         }*/7         functionShow (pic) {8             varSour = pic.getattribute (' href '));9             varplaceholder = document.getElementById (' pla ');TenPlaceholder.setattribute (' src ', sour); one         } a</script>

JavaScript learning: Photo Gallery

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.