Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery $('<div>') vs $('<div />') [duplicate]

Possible Duplicate:
$('<element>') vs $('<element />') in jQuery

Which one of these two are the correct way to do it:

$('<div>') 

or

$('<div />')

They both seem to work. Is one way more right than the other, or do they both always work?

like image 359
qwertymk Avatar asked May 01 '12 18:05

qwertymk


People also ask

How do you copy the content of a div into another div using jQuery?

First, select the div element which need to be copy into another div element. Select the target element where div element is copied. Use the appendTo() method to copy the element as its child.

How do I clone a div?

To clone a div and change its id with JavaScript, we can use the cloneNode method on the div. Then we can set the id property of the cloned element to set the ID. to add the div.

How can I duplicate a div onclick event?

To duplicate a div onclick event with JavaScript, we can call cloneNode` to clone an element. Then we can set the onclick property of the cloned element to the same event handler function as the original element. to add a div. Then we deep clone the element by calling cloneNode with true .

How copy HTML using jQuery?

To clone an element using jQuery, use the jQuery. clone() method. The clone() method clones matched DOM Elements and select the clones. This is useful for moving copies of the elements to another location in the DOM.


1 Answers

They produce identical results in jQuery.

like image 179
Blazemonger Avatar answered Oct 12 '22 15:10

Blazemonger