Calls to JavaScript functions (via nodes)--javascript DOM programming art

Source: Internet
Author: User

Question: When clicking on an image link, you can see both the picture and the original picture list on the current page

Workaround: Add a placeholder to reserve a browse area for the picture

1, add a placeholder after the list

2, change the SRC attribute of the placeholder

function Showpic (whichpic) {var Placeholder=document.getelementbyid ("placeholder");//Get the contents of the IMG element through the id attribute

var source=whichpic.getattrribute ("src");//Gets the value of the SRC attribute of the clicked Picture link

Placeholder.setattribute ("src", source);//Modify the SRC attribute of the IMG element for the currently clicked picture Link

}

3, in the picture list in the Call function

<li><a href= "img/001.jpg" onclick= "showpic (this); return false;" title= "" >Rose</a></li>

Description: This indicates that the <a> element node, return False indicates that the JS code returned to the OnClick event handler value is False, will think "this link is not clicked", so click on the link will not be taken to another image viewer.

Calls to JavaScript functions (via nodes)--javascript DOM programming art

Related Article

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.