tags:

views:

391

answers:

2

How can you remove the attribute id by jQeury?

My jQuery code

jQuery('a.no_flag_question').live('click', function(){
    jQuery.post('/codes/handlers/no_flag_question.php', 
        { question_id: jQuery(this).attr('rel') });
            $(".question_box").removeClass("yellow");   // problem here
            alert ("Question is now not spam.");
});

This code should remove the following yellow -attribute in

<div id="yellow" class="question_box">

However, this does not work. The reason is very likely the function removeClass. I apparently use wrong function, since I want to use the ID.

+11  A: 
$('.question_box').removeAttr('id')

More info at http://docs.jquery.com/Attributes/removeAttr

meder
+4  A: 

removeClass only exists because class is a multi-valued attribute... if you have a <div class="one two three"> and you call .removeClass("two") on it, it should end up with class="one three". addClass and removeClass exist to save you from doing all that work yourself. id isn't special in that way, so you just access it with attr.

hobbs