Search code examples
jqueryhtmlopera

Opera error in html5 : data-xxxx custom tag issue rewriting


i come now cause Opera is giving me more job than what a think , the problem is the next:

$('.colourbox').click( function()
{
    $('.colourbox').css('border-color','#a3a3a3');
    $('.colourbox').attr('data-selected','no');
    $('.colourbox').children().css('border-color','transparent');
    $(this).css('border-color','#222');
    $(this).children().css('border-color','#fff');
    $(this).attr('data-selected','yes');
    }

I have this code , and the problem is the next , when i do it first time , $(this).attr('data-selected','yes'); create the tag and the value , but when i try to rewrite in a second click width $('.colourbox').attr('data-selected','no'); , the data doesn't change.


Solution

  • $('.colourbox').attr('data-selected','no');

    ^ This selects every element so it may be returning all or the last value of the entire set. Try querying one at a time, eg .eg(0) to ensure and then refactor based on this.