<!DOCTYPE html>
<
html
>
<
head
>
<
script
src
=
</
script
>
</
head
>
<
body
>
<
h1
style
=
"color: #008000"
>
GeeksforGeeks
</
h1
>
<
hr
>
<
h3
>This is the "#container" div</
h3
>
<
div
id
=
"container"
>
<
em
>Lorem Ipsum</
em
><
br
>
<
strong
id
=
"name"
>
Lorem Ipsum
</
strong
><
br
>
<
u
class
=
"uname"
>Lorem Ipsum</
u
>
</
div
>
<
br
>
<
h3
>Selecting the 'em' element</
h3
>
<
div
id
=
"em-container"
></
div
>
<
h3
>
Selecting the element
with id "name"
</
h3
>
<
div
id
=
"name-container"
></
div
>
<
h3
>
Selecting the element
with class "uname"
</
h3
>
<
div
id
=
"uname-container"
></
div
>
<
script
>
// looping over the child 'em'
// elements of the "#container" div
$("#container").children('em').each(function()
{
var element = $(this).prop('outerHTML');
$("#em-container").append(element);
});
// looping over the child elements of
// the "#container" div having id as "name"
$("#container").children('#name').each(function()
{
var element = $(this).prop('outerHTML');
$("#name-container").append(element);
});
// looping over the child elements of
// the "#container" div having class as "uname"
$("#container").children('.uname').each(function()
{
var element = $(this).prop('outerHTML');
$("#uname-container").append(element);
});
</
script
>
</
body
>
</
html
>