javascript - Problem adding image overlay (jQuery) -


What do I want to do to get all the images with the name of a specific class, and put an overlay image on them . My script thus far in jQuery 1.2.6:

  jQuery.noConflict (); JQuery (document) .ready (function ($) {var module = $ (".module- contactus div div div"); module.find ("img.let"). Each (function () {var iWidth = $ ( This) .wide (); var iHeight = $ (this) .height (); var letimg = $ ('& lt; img src = "/ LET.png" style = "status: full; top: 50%; Given: 50%; Margin-top: - 'Math. Cecil (iHeight / 2) +' PX; Margin-left: - '+ Math. Cecil (Iwouth / 2) +' Px; '/ & gt;' ; Var wrapper = $ ('& lt; span style = "position: relative; display: inline-block;" & gt; & lt; / span & gt;'); $ (this). Wrap (wrapper); letimg .appendTo (wrapper);});});  

did not include letimg in the document (According to firebug). Although the duration element successfully wraps the original image. Also, if I type $ (this) to the attachment function , But then it is added inside the original image, then it works a bit!

Edit: The markup is below (additional devices are the result of Joomla .)

  & lt; Div class = "module-contactus" & gt; & Lt; Div & gt; & Lt; Div & gt; & Lt; Div & gt; & Lt; Img src = "/ contact1.jpg" /> & Lt; Img class = "walk" src = "/ contact2.jpg" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;  

The second image has been changed after the script:

  & lt; Span style = "position: relative; display: inline-block;" & Gt; & Lt; Img class = "walk" src = "/ contact2.jpg" /> & Lt; / Span & gt;  

However, it should end in such a way:

  & lt; Span style = "position: relative; display: inline-block;" & Gt; & Lt; Img class = "walk" src = "/ contact2.jpg" /> & Lt; Img src = "/ LET.png" style = "..." /> & Lt; / Span & gt;  

This has worked for me:

  Jquery no dispute (); Each function () (var iWidth = $ (this) .width (); var iHeight = ($ ("$ img.let", $ ("module-communication div div div")) $ (this). ; Var Lookimg = '& lt; img src = "http://www.roomsinworcester.co.uk/images/stories/LET.png" style = "status: full; top: 50%; left: 50%; margin -Tap: - '+ Meth. Cecil (IHight / 2) +' PX; Margin-left: - '+ Math. Cecil (Iwouth / 2) +' PX; '/' 'Var wrapper = $ (' & Lt; span style = "position: relative; display: inline-block;" gt; & lt; / span & gt; '); $ (this) .rap (cover). Later (letimg);});} );  

As a side note I took some of your variables, and said Maybe you will continue to remove others (put the IMG tag directly later, the wrapper directly into the wrap function, etc.). Though there is no big deal.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -