I'm building a webpage with the following codes:
function change ()
{
if($(this).hasClass("rosaLC"));
{
$(this).toggleClass('rosaLCb');
}
if ($(this).hasClass('rosaBC'));
{
$(this).toggleClass('rosaBCb');
}
}
On the html, the buttons that trigger this function is the follow:
<div class="row">
<article class="columnLeft">
<div class=rosa>
<button onclick="playVid('crux');change.call(this)" class=rosaLC style="top:28px; left:75px;" ></button>
<button onclick="playVid('gloria');change.call(this)" class=rosaBC style="top:460px; right:131px;"></button>
</div>
</article>
</div>
But, when the function change() is called, the if statement does not evaluate correctly, that is, when the <button> of class rosaLC is clicked, the function change () add to it both classes rosaLCb and rosaBCb, and the original class rosaLC does not come toggled, the button still with the 3 classes: <button onclick="playVid('crux');change.call(this)" class="rosaLC rosaLCb rosaBCb" style="top:20px; left:86px;"></button>
What is wrong? thanks in advance.
Aucun commentaire:
Enregistrer un commentaire