javascript - JQuery hover doesnt work -


i got jquery hover doesnt show. dimmed-item class, add on kunden-item class. bouth of them allready work if manuely put them in. jquery allready in file there must logic mistake made.

here html 1 element:

<div class="kunden-item kunde2-item">   <img class="kunde" src="<?php echo $params->get('image2');?>" alt="kunde"> </div> 

here jquery:

$(document).ready(function(){  $("kunden-item")   .mouseenter(function() {     $(this).addclass("dimmed-item");   })   .mouseleave(function() {     $(this).removeclass("dimmed-item");   }); }); 

kunden-item class, selector needs leading .:

$(".kunden-item")     .mouseenter(function() {         $(this).addclass("dimmed-item");     })     .mouseleave(function() {         $(this).removeclass("dimmed-item");     }); }); 

also note can massively shorten code using hover() , toggleclass():

$(".kunden-item").hover(function() {     $(this).toggleclass('dimmed-item'); }); 

or using css alone:

.kunden-item:hover {     opacity: 0.5; // example only, apply whatever style need here } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -