dom - How to insert a piece of code programmatically using jQuery? -


I am learning jQuery and I would like to use it to solve the old problem I have a piece of HTML code program I want to use jQuery to add. What I need to do: To create a jQuery function, all elements / objects are inside "code">

"When my function gets the img object, then I would like to put img inside another div .

To clarify things, assume that my work code :

  
lt; img height = "200" width = "300" src = "image -2.jpg "title =" my image 1 "class =" alignonone Car-media wp-image-25 "> em> This is my image! ; p> Advertising Ready for Advertising In addition to this, Lt; / p & gt; & lt; img height = "400" width = "250" src = "image-2.jpg" title = "My image 2" class = " Alignment size-medium WP-image-25 "> em> This is another image!

I would like to write a jQuery function that changes it to :

   This is my image! & Lt; / Em> & Lt; P & gt; Advertising Ready for Advertising In addition to this, you live your life completely during your lifetime. & Lt; / P & gt; & Lt; Div class = "main-image" & gt; & Lt; Img height = "100" width = "200" src = "image-2.jpg" title = "my image 2" class = "attachment-single-post-image wp-post-image" & gt; & Lt; / Div & gt; & Lt; Em> This is another image! & Lt; / Em> & Lt; P & gt; Advertising Ready for Advertising In addition to this, you live your life completely during your lifetime. & Lt; / P & gt; & Lt; / Div & gt;  

Then, "basically" what do i want to do:

  1. between all img objects & Lt; Div class = "main-image" & gt; and & lt; / Div & gt; ;
  2. img to the class attachment-single-post-image wp-post-image ;
  3. Change the img height to 100 ;
  4. Change the img width to 300 .

this is :)

I do not know if my explanation is clear. Unfortunately I'm not a "native" English speaker.

entry
Var img = $ ("img", searchScope) .attr ("height", 100) .attr ("width", 300) .removeClass () .addClass ("attachment- single-post-image WP-post-image" ) .wp ("

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -