How to switch image based on anchor tag using jQuery? -


I have a list of thumbnail images when the user clicks on a small thumbnail image, to show this full image It swaps. I'm trying to get the anchor tag name so that I can blast value i . But I am working on it, no idea?

My Javascript:

  Function swap (image) {document.getElementById ("main"). Src = image .href; }  

My HTML & amp; PHP Script:

  & lt; Img id = "main" src = "images / main.jpg" width = "226" height = "226" alt = "" /> & Lt; P & gt; & Lt; Strong & gt; Day & lt ;? Php echo $ i; ? & Gt ;: & lt; / Strong> & Lt; / Strong> & Lt; Br / & gt; & Lt ;? Php echo $ today [$ i]; ? & Gt; & Lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;? For Php ($ i = 1; $ i & lt; $ day; $ i ++) {echo '& lt; A href = "picture / predecessor - '. $ I.' .jpg" name = "day - '. $ I." "Onclick =" swap (this); Return back; "& gt; 'echo' & lt; img src =" images / thumbDay - '. $ I. '. Jpg "width =" 50 "height =" 50 "alt =" "title =" thumb-de-' $ I. 'Jpg' /> & lt; / a & gt; ';}? & Gt;  

  $ (" # days "). -1 ")  

or without jQuery, if you really want to get it by name:

  $ (" a [name = '] Day-1 '] ") 

code>

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -