flix_is_here22 Posted September 26, 2012 Share Posted September 26, 2012 (edited) hi this is my code....how to get click value from href and then show a picture on div layer....?? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><style>#layer{ top:0; left:0; height:100%; width:100%; position:absolute; background-color:blue; display:none; opacity:0.5; color:red;}#asd{ color:red; }</style><script type="text/javascript" language="JavaScript"><!--function HideContent(d) {if(d.length < 1) { return; }document.getElementById(d).style.display = "none";}function ShowContent(d) {var img=new Array();img[0]="a.jpg"; img[1]="b.jpg";img[2]="c.jpg"; if(d.length < 1) { return; }document.getElementById(d).style.display = "block";}function ReverseContentDisplay(d) {if(d.length < 1) { return; }if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }else { document.getElementById(d).style.display = "none"; }}//--></script> </head><body><div><a onclick="ShowContent('layer'); return true;" href="javascript:ShowContent('layer')" name="show1" title="show1">[show>>>>> 1]</a><a onclick="ShowContent('layer'); return true;" href="javascript:ShowContent('layer')" name="show1" title="show2">[show>>>>> 2]</a> </div><div id="layer" >Content goes here.<a onclick="HideContent('layer'); return true;" href="javascript:HideContent('layer')" ><img src="" id="show1"/>[hide>>>>>> 1]</a></div> <!--<a onmouseover="ReverseContentDisplay('layer'); return true;" href="javascript:ReverseContentDisplay('layer')">[show/hide]</a>--> </body></html> Edited September 26, 2012 by flix_is_here22 Link to comment Share on other sites More sharing options...
bittu4u4ever Posted October 4, 2012 Share Posted October 4, 2012 donot use the same function call in href and return true in onclick. it executes twice. use it as following function ShowContent(e, d) {var img=new Array();img[0]="a.jpg";img[1]="b.jpg";img[2]="c.jpg";// e.target.href ... this gives you the href value of clicked elementif(d.length < 1) { return; }document.getElementById(d).style.display = "block";} <a onclick="ShowContent(event, 'layer'); return false;" href="javascript:ShowContent('layer')" name="show1" title="show1">[show>>>>> 1]</a> Link to comment Share on other sites More sharing options...
es131245 Posted October 5, 2012 Share Posted October 5, 2012 for jQuery $('a.specialLinks').click(function(){ $('#divId').html('<img src="'+this.child().src+'" alt="description" />');}); thats the idea... I must've mabe few errors (cant get anything to work strait away =) ) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now