List Item Bullet Color different List Text Color

Recently ran into a design that asked for list items to have a different color for the bullet than the accompanying text. Rather than use a bullet image - the design was using the default bullet styles after all - I Came up with a quick solution with jQuery that I figured I'd share.

I started by setting the li color to the color I wanted the bullets to be. We'll go with skyblue for this.

Remember though, we don't want the text to be skyblue , just the bullet. The next ul will get a class for our jQuery to target. We're also going to create a css property for spans appearing inside an li that contains the color we want it to be. In this case I want the color to be the same as the text color on the rest of the page - white.

Now we just write a quick bit of jQuery to wrap all of the text inside these li in spans. My code varies a bit so you can see the difference but you could use something like:


  (function($) {
      var listItems;

      function onDocumentReady() {
        listItems = $("li");

        listItems.wrapInner("<span />");
      }

    $(onDocumentReady);
    
  })(jQuery);
  
  

Voila! skyblue bullets and white text:

This will work for ordered lists as well if you want it to. You could change your jQuery context to only target li inside ul if you needed to: $('ul').find('li'); would do the trick.

  1. If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar. I believe you will find the dessert to be both engrossing and high-grossing! So we don't get dessert? The worst that could happen is that I could spill coffee all over this $3,000 suit.
  2. COME ON. "Circumvent." It means "to go around." Gob: The old "reach around." I'm gonna build me an airport, put my name on it. Why, Michael? So you can fly away from your feelings? Daddy horny, Michael.
  3. Someone order 140 pounds of upper body strength? But anyhoo, can you believe that the only reason the club is going under is because it's in a terrifying neighborhood? It's so watery. And yet there's a smack of ham to it. Gosh Mom… after all these years, God's not going to take a call from you.

Have you encountered this problem? What's your go-to solution? Let me know in the comments. If you have questions you can tweet @thatseandempsey or email, skd.developer@gmail.com.