0

I have an LI element "add folder" that uses a css pseudo before element to add a plus, like so:

enter image description here

the LI has a class of "add" and I have jquery that fires when "add" is clicked and CSS on the LI to show a cursor.

Of course, the pseudo element is not active. I realize that pseudo elements are not part of the DOM, but how would you handle this sort of thing (preferably without resorting to an IMG tag) so the words AND the plus mark can be clicked?

Here is the CSS for the plus:

li.add:before {
    content: "\002B";
    display: inline-block;
    padding: 0 5px;
    margin-right: 5px;
    background: $orangelight;
}
6
  • Just looking at that list item, the plus mark should be a child, not a sibling (which would solve your problem)... Perhaps refactor your markup? Commented Mar 6, 2013 at 18:55
  • The plus mark is not a sibling, it's assigned to the before pseudo element of the LI tag. Commented Mar 6, 2013 at 18:58
  • 1
    Is this a correct setup? jsfiddle.net/WhDY9 Commented Mar 6, 2013 at 19:01
  • @Steve: Then it should work as is (i.e. event should fire even when the plus sign is clicked). If it doesn't, something else is wrong. Commented Mar 6, 2013 at 19:03
  • @Ramunas You've created your fiddle just seconds faster :-) Commented Mar 6, 2013 at 19:04

1 Answer 1

3

It works perfectly fine here: http://jsfiddle.net/Un4gq/

$("li").on("click", function () {
    alert("click");
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.