How does JQuery delete the last li of UL
This article mainly explains "how to delete the last li of UL by JQuery". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "JQuery how to delete the last li of UL"!
JQuery delete the last li of UL: 1, create a list using the ul li tag; 2, create a button using the button tag and bind the onclick click event to the button; 3, get the last li through the jquery selector ": last" and delete it using the remove method.
This article operating environment: Windows7 system, jquery3.2.1 version, DELL G3 computer
How does JQuery delete the last li of UL?
Create a new html file, named test.html, to explain how jquery deletes the last li element.
In the test.html file, use the ul, li tags to create a list for testing.
In the test.html file, set the id of the ul tag to mytest, which is used to get the ul object below.
In the test.html file, create a button using the button tag, bind the onclick click event to button, and execute the delli () function when the button is clicked.
Within the js tag, create the delli () function. Within the function, get the last li tag object through the jquery selector ": last" and delete it using the remove () method.
Open the test.html file in the browser and click the button to view the results.
At this point, I believe you have a deeper understanding of "JQuery how to delete the last li of UL". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!