---
title: "Jquery: Append a Class on hover of a div and remove when not hover"  
description: "Jquery: Append a Class on hover of a div and remove when not hover"  
author: "Samuel Fernandes"  
published: 2013-05-11  
updated: 2013-05-11  
canonical: https://www.mindstick.com/forum/868/jquery-append-a-class-on-hover-of-a-div-and-remove-when-not-hover  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Jquery: Append a Class on hover of a div and remove when not hover

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!\
I want to append a [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) to a div on hover of that div and [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) that class when its not on hover. And when I hover on another div, again this class should be \
appended and removed when its not on hover. Someone [say](https://answers.mindstick.com/qa/116645/a1-wreckers-reviews-what-do-customers-say) me how to do it in jquery......\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!\

## Replies

### Reply by AVADHESH PATEL

Hi Samuel!\
replace addClass and removeClass functions in jquery as following \
$(document).ready(function() { $('#secID, #thID').hover(function(){ $('#oneID').addClass('red'); }, function(){ $('#oneID').removeClass('red'); });}); \
I hope it is useful to you


---

Original Source: https://www.mindstick.com/forum/868/jquery-append-a-class-on-hover-of-a-div-and-remove-when-not-hover

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
