Adding Fields(block) Using jQuery clone()

jQuery clone() creates a copy of matched element. It comes in handy since it does not only creates a copy of matched elements but also, all of their descendant elements and text nodes.
Hello
World
Result
Hello
World
World
The above code creates a clone of div with class as world and appends it to div with class hello.
Using clone(), we can create "Add more" without using any external js files or plugins
FULL CODE
HTML
Price
Add More +
CSS
.close{
  cursor:pointer;
 }

JQUERY

Try It In FIDDLE Yourself

Comments

Popular posts from this blog

jquery attr() vs prop() (difference)

jQuery popup (dialog) form validation on a normal button click

Jquery :contains and making it Case-Insensitive