Last active
December 22, 2015 20:39
-
-
Save kevinvess/6528045 to your computer and use it in GitHub Desktop.
This javascript/jquery snippet will allow you to dynamically change the bullet color of all unordered lists in a given content block while keeping the original text color set by the CSS. This is particularly useful when dealing with a CMS that will output the content block and the design calls for the bullet color to be different than the text c…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>list bullet color change demo</title> | |
<style> | |
body { | |
color: #666; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="content"> | |
<ul> | |
<li>Only the bullet color changes.</li> | |
<li>This text color should still inherit the color set by the styles</li> | |
</ul> | |
</div> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
<script src="script.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(window).load(function(){ | |
var bulletColor = '#3399FF'; | |
$('.content ul').not('nav ul').each(function() { | |
var li = $(this).find('> li'); | |
var liColor = $(this).css('color'); | |
li.wrapInner('<span />'); | |
li.find('span').css('color', liColor); | |
li.css('color', bulletColor); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment