Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

jQuery wrap elements

Автор: kudvenkat

Загружено: 2015-04-16

Просмотров: 65457

Описание:

Link for all dot net and sql server video tutorial playlists
https://www.youtube.com/user/kudvenka...

Link for slides, code samples and text version of the video
http://csharp-video-tutorials.blogspo...

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
   / @aarvikitchen5572  

In this video we will discuss how to wrap and unwrap elements

The following jquery methods are used to wrap and unwrap elements. Since these methods modify DOM, they belong to DOM manipulation category.
wrap
unwrap
wrapAll
wrapInner

wrap - Wrap an HTML structure around each element in the set of matched elements.

Consider the following HTML
<div id="div1">
DIV 1
</div>
<div id="div2">
DIV 2
</div>
<div id="div3">
DIV 3
</div>

The following line of code wraps each of the above div element with another div element.
$('div').wrap('<div class="containerDiv"></div>');

So the HTML in the DOM would now look as shown below. To view the DOM HTML use the browser developer tools.
<div class="containerDiv">
<div id="div1">
DIV 1
</div>
</div>
<div class="containerDiv">
<div id="div2">
DIV 2
</div>
</div>
<div class="containerDiv">
<div id="div3">
DIV 3
</div>
</div>

Example :
<html>
<head>
<title></title>
<style>
.containerDiv
{
background-color:red;
color:white;
font-weight:bold;
margin: 5px;
}
</style>
<script src="jquery-1.11.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
alert($('div.containerDiv').length);
$('div').wrap('<div class="containerDiv"></div>');
alert($('div.containerDiv').length);
});
</script>
</head>
<body style="font-family:Arial">
<div id="div1">
DIV 1
</div>
<div id="div2">
DIV 2
</div>
<div id="div3">
DIV 3
</div>
</body>
</html>

unwrap - Remove the parents of the set of matched elements from the DOM.

Example :
<html>
<head>
<title></title>
<style>
.containerDiv
{
background-color:red;
color:white;
font-weight:bold;
margin: 5px;
}
</style>
<script src="jquery-1.11.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
alert($('div.containerDiv').length);
$('div').wrap('<div class="containerDiv"></div>');
alert($('div.containerDiv').length);
$('div').unwrap();
alert($('div.containerDiv').length);
});
</script>
</head>
<body style="font-family:Arial">
<div id="div1">
DIV 1
</div>
<div id="div2">
DIV 2
</div>
<div id="div3">
DIV 3
</div>
</body>
</html>

wrapAll - Wrap an HTML structure around all elements in the set of matched elements.

Consider the following HTML
<div id="div1">
DIV 1
</div>
<div id="div2">
DIV 2
</div>
<div id="div3">
DIV 3
</div>

The following line of code wraps all of the matching div element with another div element.
$('div').wrapAll('<div class="containerDiv"></div>');

So the HTML in the DOM would now look as shown below.
<div class="containerDiv">
<div id="div1">
DIV 1
</div><div id="div2">
DIV 2
</div><div id="div3">
DIV 3
</div>
</div>

wrapInner - Wrap an HTML structure around the content of each element in the set of matched elements.

Consider the following HTML
<div id="div1">
DIV 1
</div>
<div id="div2">
DIV 2
</div>
<div id="div3">
DIV 3
</div>

The following line of code wraps each of the above div element content with another div element.
$('div').wrapInner('<div class="containerDiv"></div>');

So the HTML in the DOM would now look as shown below.
<div id="div1">
<div class="containerDiv">
DIV 1
</div>
</div>
<div id="div2">
<div class="containerDiv">
DIV 2
</div>
</div>
<div id="div3">
<div class="containerDiv">
DIV 3
</div>
</div>

jQuery wrap elements

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

jQuery append elements

jQuery append elements

jQuery each function

jQuery each function

Я ненавижу длинные цепочки If-Elif: этот шаблон проектирования решил эту проблему раз и навсегда

Я ненавижу длинные цепочки If-Elif: этот шаблон проектирования решил эту проблему раз и навсегда

jquery ajax load

jquery ajax load

$1 vs $1,000,000,000 Футуристических Технологий!

$1 vs $1,000,000,000 Футуристических Технологий!

jQuery tutorial for beginners

jQuery tutorial for beginners

SHAZAM Top 50🏖️Лучшая Музыка 2025🏖️Зарубежные песни Хиты🏖️Популярные Песни Слушать Бесплатно #40

SHAZAM Top 50🏖️Лучшая Музыка 2025🏖️Зарубежные песни Хиты🏖️Популярные Песни Слушать Бесплатно #40

Эксперт (Короткометражка, Русский дубляж)

Эксперт (Короткометражка, Русский дубляж)

НАЧИНАЙ УТРО С ЭТОГО!!!

НАЧИНАЙ УТРО С ЭТОГО!!!

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

Детали переговоров по Украине в Абу-Даби. Стратегия обороны США. Удар по Киеву: 800 тысяч без света

Детали переговоров по Украине в Абу-Даби. Стратегия обороны США. Удар по Киеву: 800 тысяч без света

Самые Нелепые Ошибки Рабочих, Снятые на Камеру

Самые Нелепые Ошибки Рабочих, Снятые на Камеру

Перетест Ai MAX+ 395 в жирном мини-ПК и тест AMD 8060s vs Intel B390

Перетест Ai MAX+ 395 в жирном мини-ПК и тест AMD 8060s vs Intel B390

Difference between $ each and  each

Difference between $ each and each

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

Селектор значений атрибута jQuery

Селектор значений атрибута jQuery

jQuery DOM manipulation methods

jQuery DOM manipulation methods

What is JSON

What is JSON

jQuery method chaining

jQuery method chaining

jQuery checked selector

jQuery checked selector

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com