Click to download, you can download the parent sibling node
<Divclass= "Form-group"> <Div> <H3>Applicant Information</H3> <Divclass= "Sq_info"> <ul> <Li><span>Name:</span><P>Tom</P></Li> <Li><span>Name:</span><P>Tom</P></Li> <Li><span>I Photo:</span><imgsrc= "Http://pic.pptbz.com/201506/2015070581208537.JPG"alt=""><ahref= "javascript:void (0);"onclick= "down_img (this)">Click to download</a></Li> <Li><span>Passport Homepage:</span><imgsrc= "Https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=302701032,2300144492&fm=27&gp=0.jpg" alt=""><ahref= "javascript:void (0);"onclick= "down_img (this)">Click to download</a></Li> <Li><span>Price:</span><Pclass= "Price">500 USD</P></Li> </ul> </Div> </Div> <Div>
<script>functionMybrowser () {varuseragent = navigator.useragent;//get the useragent string for the browservarIsopera = Useragent.indexof ("Opera") >-1;if(Isopera) {return"Opera"}; //determine if Opera browserif(Useragent.indexof ("Firefox") >-1) {return"FF";} //determine if Firefox browserif(Useragent.indexof ("Chrome") >-1) {return"Chrome";}if(Useragent.indexof ("Safari") >-1) {return"Safari";} //determine if Safari browserif(Useragent.indexof ("compatible") >-1 && useragent.indexof ("MSIE") >-1 &&!Isopera) {return"IE";}; //determine if IE browserif(Useragent.indexof ("Trident") > 1) {return"Edge";} //determine if the Edge browser}//②ie Browser picture save (ie actually use is window.open)functionSaveAs5 (imgurl) {varOPop = window.open (Imgurl, "", "width=1, Height=1, top=5000, left=5000"); for(; OPop.document.readyState! = "complete";) {if(OPop.document.readyState = = "complete") Break;} OPop.document.execCommand ("SaveAs"); Opop.close ();}//④ Click event Download (just change the picture path)functionDown_img (a) {varOSB =A;varSB =a.previoussibling.src;//console.log (SB)if(Mybrowser () = = = = "IE" | | mybrowser () = = = "Edge") {//IE (browser)SaveAs5 (SB);} Else {//! IE (non IE)Osb.href =Sb;osb.download= "";}}</script>
Note: PreviousSibling take the parent sibling node, note that there can be no spaces between the labels, otherwise there will be undefined
Native JS Implementation click to download pictures