Sunday 15 August 2010

html - CSS or jQuery to cut down on matching A HREF and IMG SRC? -


I got to go to some Web sites that I manage, and thumbnail images (which may include the lightbox or Fansiboks ), Lines are of great size:

  & lt; A href = "http://www.site.com/images/this-would-be-the-picture-we-want-x-treat-size.jpg" & gt; & Lt; Img src = "http://www.site.com/images/this-would-be-the-picture-we-want-x-plus-image.jpg" "width = 200> gt; & lt; / A & Gt;   

I have no exemption on the full path (many people posting pages again) or shortening file names (there are so many pictures in it), there The path is not

It would be easy to do with jQuery - for example ...

  $ ('img') .click (function () {window.location.href = $ (this) .attr ('src');});   

However, This is just a link to copy Yvhar - you also should see your lightbox code works, it & lt; a & gt; is links can be used as a trigger that can bypass using up .

If you want to do this in another way (only on the link), I can do something when the page loads.

  $ (document) Ready (function () {$ ('one') Each (function () {$ (this) .append ('& lt; img src = "' + $ (this) .attr ('href') + 'width =" 200 "& gt;');}) ; });   

However, it does not appear for every & lt; A & gt; will address the link so that you want to use a class to trigger this behavior.

No comments:

Post a Comment