I have various a elements that i get with this jQuery selector:
$("#toc").find("li a")
If one element text is “first second” (and all elements’ text are two words divided by a space) I want to show only the first word, in this example the element’s text should be first, is this possible?
You could wrap the second word in a
span, and hide that:JS Fiddle demo.
With the CSS:
To address situations where there might be more than two words:
JS Fiddle demo.