How To Change Text Color on Hover With jQuery

This article demonstrates how to change the text color during hover with jQuery. Included are usable example code and a CDN link for jQuery.

This article was first seen on and republished from

How To Change Text Color on Hover With jQuery
How To Change Text Color on Hover With jQuery


The HTML provided below constructs a simple HTML menu with four menu items.

<ul class="menu">


This CSS code gives the menu structure and visibility for this example.

html {
  font-family: Roboto, arial, sans-serif;
  background: rgb(28, 65, 97);
  background: linear-gradient(
    rgba(28, 65, 97, 1) 0%,
    rgba(123, 49, 150, 1) 0%,
    rgba(28, 65, 97, 1) 100%

.active {
  color: white;

ul {
  list-style: none;
  background: #6b83de;

ul li {
  cursor: pointer;
  display: inline-block;
  margin: 10px;

.menu {
  width: 365px;
  margin: 10% auto 0 auto;
  border-radius: 4px;

Google CDN:

<script src=""></script>

Including jQuery library from the google CDN provides a benefit. Many users visit sites that already include this library from the Google CDN. As a result, the library is already cached in your browser whenever you visit a new website with this script included. This ultimately provides faster downloading of the web page.


This jQuery code adds a class to the element on hover and removes the class whenever the cursor leaves the element.

$('.menu li').hover(function() {
function() {

View the code example on

Recommended Articles