Preface.
Bạn đang xem: Introducing Some Jquery Functions That Affect Html Tags For Students
Today I’m talking about using some functions that affect html tags in jquery. I hope this article can be helpful for students who are new lớn jquery.mục lục: 1, Hàm append().2, Hàm prepend().3, Hàm after().4, Hàm before().5, Hàm empty().6, Hàm remove().7, Lời kết.
1, Append () function.
-The append () function in Jquery works to lớn insert nội dung into the back of the component lớn impact. Syntax: $("selector").append(content); In it: nội dung is the content that you need lớn add.
For example: $("p").append("Toidicode.com");
demo
2, The prepend () function.
-The prepend () function in Jquery works to lớn insert nội dung into the beginning of the component to lớn impact.
Syntax:
$("selector").prepend(content); In it: nội dung is the nội dung that you need to add.
For example:
$("p").prepend("Toidicode.com, ");
demo
3, After () function.
-The after () function in Jquery works to lớn insert content into the back of the component to lớn impact.
Syntax:
$("selector").after(content); In it: nội dung is the nội dung that you need lớn add.
Xem thêm: Tình Dục Là Chuyện Nhỏ Diễn Viên, Nữ Chính Phim Tình Dục Là Chuyện Nhỏ Qua Đời
For example:
$("p").after("
Toidicode.com
"); demo
4, Before () function.
-The before () function in Jquery works lớn insert content into the front of the component that needs impact.
Syntax:
$("selector").before(content); In it: nội dung is the nội dung that you need to lớn add.
For example:
$("p").before("
Toidicode.com
");
demo
5, The function empty ().
-The empty () function in Jquery works khổng lồ empty the nội dung of the component that needs impact.
Syntax:
$("selector").empty(); For example:
$("p").empty(); demo
6, The remove () function.
-The remove () function in Jquery has the effect of deleting the selected components.
Syntax:
$("selector").remove(argument); Inside:
If the remove () function is left blank, it clears all the components within the selected component. If you want to delete specific components, just danh mục the components khổng lồ delete in the remove () function. Example: Delete all tags p.
$("p").remove(); demo
Example: Delete all p. Tags whose class is ‘demo’.
$("p").remove(".demo"); demo
Example: Delete all p tags whose class is ‘demo’ or id is ‘des’.
$("p").remove(".demo, #des"); demo
7, Conclusion
So I have introduced through 8 functions that affect HTML tags. I think it is very useful for those new khổng lồ Jquery. Thank you for your interest in your article.
Share the news now
Source : Viblo
Interested in changing your career?
Senior Full-Stack Lead/Developer - Capgemini Vietnam
JavaScript jQuery Bootstrap
Negotiable
Phú Nhuận, TP hồ nước Chí Minh
Java Developer - Nissho Vietnam
Java JavaScript jQuery
15,000,000 VND - 35,000,000 VND
Đống Đa, Hà Nội
Technical Architect - NashTech
Java MVC HTML
Negotiable
Tân Bình, TP hồ Chí Minh
Senior website Developer - ColigoMed
JavaScript ReactJS HTML
Negotiable
tung Binh, TP hồ nước Chí Minh
Technical Services Specialist - SecuTix
JavaScript HTML CSS
Negotiable
Bình Thạnh, TP hồ nước Chí Minh

Be up lớn date with the latest and most popular news
Latest news
xiaomi mi 12 Lite launched in Vietnam: Youthful design, 108MP camera, priced at 9.9 million VND
September 10, 2022"Hybrid cars are out of time" – Toyota, Honda, Nissan have woken up?
September 10, 2022Popular articles