I'm trying to remove every li I click on. This is the ordered list I have:
<ol id="list">
<li id="0" class="newItems" onclick="Removeli();">G6000BJ</li>
<li id="1" class="newItems" onclick="Removeli();">G6000Bk</li>
<li id="2" class="newItems" onclick="Removeli();">G6000BN</li>
<li id="3" class="newItems" onclick="Removeli();">G6000BW</li>
<li id="4" class="newItems" onclick="Removeli();">G6000BT</li>
<li id="5" class="newItems" onclick="Removeli();">G6000BR</li>
<li id="6" class="newItems" onclick="Removeli();">G6000BE</li>
</ol>
and this the jQuery code I'm using:
function Removeli() {
$('.newItems').click(function () {
$(this).remove();
});
}
But I am not able to delete the last one when I click on it. This means that when I'm left with only one, I can't delete it. But everything else works fine. What am I doing wrong?