Select Text without Tag in jQuery | DOM Manipulation

preview_player
Показать описание
This tutorial is about DOM manipulation without having control over HTML. Get text without HTML element using jQuery. Get text without tags with jQuery in HTML or retrieve text not nested in child tags. Wrap text within element and apply a class to it. How can we select text in HTML that is without any tag? And how to select text at any index level without any tag, wrap it in a tag and apply a class to it?

In our HTML, each li tag has label with input. After label we have simple text without tag. If we have to style that text then we need to select it. When the DOM is loaded, for each li item we will get contents of element and apply jQuery eq method for required index available in contents.

So this is how we can target the contents at any index level. jQuery eq reduces set of matched elements to the one at the specified index. After we have the desired text, we can wrap it with an HTML tag and apply class to it for styling or any other purpose. So even when there is no tag around text and text is inside other elements, we can select and target it like this.

Thank You!
👍 LIKE VIDEO
👊 SUBSCRIBE
🔔 PRESS BELL ICON
✍️ COMMENT

#jQuery #DOM #JavaScript #WebStylePress #WebDevelopment #html #css #jquery #jquerytutorial
Рекомендации по теме
join shbcf.ru