0

Nowadays i have problem with adding class in my script. I have unique html structure. So i need your advice. I hope that you help me.

The below there is my html code

<ul>
    <li> <a href="#" onmouseover=changeImage( 'CT')>
            <span class="CT"> CT&amp;M</span>
            <span class="CT">(blablabla)</span>
        </a>

    </li>
    <li> <span>/</span>

    </li>
    <li> <a href="#" onmouseover=changeImage( 'Invest')>
            <span class="Invest">Invest</span>
            <span class="Invest">(blablabla)</span>
        </a>

    </li>
</ul>

Look down. there is my css

aside ul li a span:first-child, aside ul li span:first-child {
    display: block;
    text-align: center;
    font-family: "Roboto-Medium";
    font-size: 1.8em;
    color: #060606;
}
aside ul li a span:last-child {
    display: block;
    text-align: center;
    font-family: "Roboto-Medium";
    font-size: 1.05em;
    color: #060606;
}
aside ul li a span.active
{
    color: #007582;
}
aside ul li a span.disactive
{
    color: #060606;
}

And here is my jQuery code:

$(function () {
    $(".CT").one("mouseover", function () {
        $("span.Invest").removeClass("active");
        $("span.CT").addClass("active");
    });

    $(".Invest").one("mouseover", function () {
        $("span.CT").removeClass("active");
        $("span.Invest").addClass("active");
    });
}); 

I would like doing interesting visual efect. I want to change color when I run onmouseover event but my script don't work properly. Could you ghelp me??

When you have any questions, you write to me.

4
  • JSFiddle demo Is that what you want? Commented Jul 11, 2013 at 17:29
  • How does it not work properly? Commented Jul 11, 2013 at 17:32
  • when i run few times onmouseover events my color isn't change you should traying it code Commented Jul 11, 2013 at 17:35
  • I delete span.disactive because i don't use it Commented Jul 11, 2013 at 17:51

1 Answer 1

1

You need to use $(".CT").on(" instead of $(".CT").one("

Using one will unbind the event after the first time the event is fired.

one() vs on()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.