Click here to Skip to main content
15,868,128 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, can i delete only first element in li?

for example:

  • type1
  • type2


i want to delete type1.
Posted

You can give an id to to the li elements like "l1", "l2" etc. and using the remove method of jQuery you can remove it like followng.


$("#l1").remove();
 
Share this answer
 
Suppose you have UL item like this below

<ul>
<li>Type1</li>
<li>Type2 </li>
</ul>


Then your jquery code will be

$('ul li:first').remove();


OR
$('ul li:eq(0)').remove();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900