Jquery ändern Sie die Deckkraft der div auf Klick

Gelesen habe ich verschiedene Fragen zu diesem Thema, aber ich habe nicht eine Lösung gefunden für meinen speziellen Fall.
Ich brauche zum ändern der Deckkraft des thumbUp und thumbDown divs, wenn Sie angeklickt werden. Warum funktioniert mein code nicht funktioniert?

Danke.

HTML

<body>
<div id="container">
    <div id="foto">
        <img src="images/feu.jpg">
    </div>
    <div id="descrizione">
        <p class="title">Feu d'artifice</p>
        <p>Giacomo Balla<br>
           1916-1917<br>
        </p>
        <div id="likeButtons">
            <p>Ti piace quest'opera?</p>
            <img id="thumbUp" src="images/thumbup.png">
            <img id="thumbDown" src="images/thumbdown.png">
        </div>
    </div>
    <div id="pulsanteOpera" class="pulsante" style="padding: 30px 20px 0 0;float:right;">
        <a href="#"></a>
    </div>    
</div>
</body>

CSS

#likeButtons{
position:relative;
right:-50%;
width:500px;
overflow:hidden;
font-weight:300;
margin-bottom:50px;
} 

#likeButtons p{
float:left;
}

#likeButtons img{
width:10%;
margin-bottom:30px;
padding-left:10px;
float:left;
cursor:pointer;
}

#thumbUp,#thumbDown{
opacity:0.6;
}

JQuery

<script>
    $(document).ready(function(e) {
        $('#pulsanteOpera').click(function(){
    $(this).toggleClass('pulsante').toggleClass('pulsanteRimuovi');
        });
    $('#thumbDown').click(function(){
            if($(this).css('opacity')==0.6)
        $(this).css('opacity','1.0');
        else
        $(this).css('opacity','0.6');
    });
    });
</script> 
  • anstelle der überprüfung für Wert aus der CSS-Eigenschaft, sollten Sie nur hinzufügen/entfernen einer Klasse
InformationsquelleAutor The Condor | 2013-11-23
Schreibe einen Kommentar