I have an <ul>
element and within it some <li>
elements. The list item contains some content before the actual item by removing the standard dot with an x using list-style-type: none;
and :before
HTML
<ul id="list1" class="basic">
<li>space</li>
<li>planet</li>
<li>planet2</li>
</ul>
CSS
ul li:before {
content:"x";
position:relative;
left:-25px;
}
JQuery
$("#list1").sortable();
$("#list1").disableSelection();
$("#list1").on("click", "li", function () {
$(this).remove();
});
The idéa here is that when i click on the "x", the list item should be removed. But it does not matter where a user clicks since the remove function applies to the whole element.
So the question is: Is it possible to make only the "x" clickable to remove the whole item?
Full code on the JSfiddle:
https://jsfiddle.net/L15kygu4/
EDIT: It seems like th best way of accomplishing this is by making a <span>
element and attach a click event to it rather than using pseudo-elements.