jquery - Using .load() function -


I am trying to load some image from anchor tag.

  & lt; A href = "localhost \ system \ upload \ lead \ test .jpgg" class = "image" & gt; & Lt; / A & gt; & Lt; Div id = "preview" & gt; & Lt; / Div & gt;  

The image is loaded on the page that I specified. Here's the code I'm using:

  $ (document) .on ("click", ". Image", function (e) {$ ("# preview"). ($ (This) .attr ('href'));});  

Am I doing something wrong? Please suggest me some solutions. Thank you.

Try to use instead:

  $ (document) ) .on ("click on" "image", function (e) {e.preventDefault (); var href = $ (this) .attr ('href'); $ ("# preview"). Html ( '& Lt; img src = "' + href + '" />);});  

or:

  $ (document) ) .on ("click", "image", function (e) {e.preventDefault (); $ ("# preview"). Html ($ ("(lt; img / & gt;"). Attr (" Src ", this.href));});  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -