Sunday, February 10, 2013

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

No comments:

Post a Comment