0

ı want to change a specific style of div by its id. However, it seems it is not working at all. The necessary codes are below:

Jquery:

$(document).ready(function () {

$(".a_10.08.201223:56:49").hover(function(){
        $("#10.08.201223:56:49").removeClass('arrow-up').addClass('arrow-up2');

    }).mouseout(function(){
        $("#10.08.201223:56:49").removeClass('arrow-up2').addClass('arrow-up2');        
    });
});

HTML:

    <div class = "a_10.08.201223:56:49">

    Something in here

        <div class="arrow-up" id="10.08.201223:56:49"></div>
</div>

The idea is that this ids are the date of the comments. For instance, 10.08.201223:56:49 id a date for a specific comment and a_10.08.201223:56:49 class represents the area to be triggered. When it is hovered through the upper div, the child div(arrow) will be displayed. When mouse is out of the upper div, the arrow will be disappered. It seems that i could not do it so far. Thanks

3
  • 1
    ID shouldn't start with a number. Commented Aug 12, 2012 at 0:18
  • Iam not sure but maybe the . in the Ids causes the problem? Commented Aug 12, 2012 at 0:21
  • Dot (.) is a reserved character for class selector. try replacing dot with underscore or escape it. Commented Aug 12, 2012 at 0:27

1 Answer 1

3

You have to escape special character used in jquery selector e.g : , . etc.

Live Demo

$(document).ready(function () {

$(".a_10\\.08\\.201223\\:56\\:49").hover(function(){

        $("#10\\.08\\.201223\\:56\\:49").removeClass('arrow-up').addClass('arrow-up2');

    }).mouseout(function(){
        $("#10\\.08\\.201223\\:56\\:49").removeClass('arrow-up2').addClass('arrow-up2');        
    });
});​
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.