tabs - Why isn't my jQuery script working? -
$(document).ready(function(){ $('.footer-item').hover(function(){ $(this).addclass(active); $('.footer-item active').removeclass('active'); }); });
basically want script change class on active icon looks more transparent, , icon being hovered on made more transparent adding class.
you have couple issues code.
- you need remove active class first, otherwise adding active, , removing (essentially doing "nothing".)
- 'active' in addclass should string.
the correct selector element footer-item , active class '.footer-item.active'
$(document).ready(function(){ $('.footer-item').hover(function(){ $('.footer-item.active').removeclass('active'); $(this).addclass('active'); }); });
$(document).ready(function(){ $('.footer-item').hover(function(){ $('.footer-item.active').removeclass('active'); $(this).addclass('active'); }); });
.active { background: red; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="footer-item">item 1</div> <div class="footer-item">item 2</div> <div class="footer-item">item 3</div> <div class="footer-item">item 4</div>
Comments
Post a Comment