To `removeID` for jQuery as` removeClass`

How to remove attribute idusing jQuery?

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 next yellow attribute in

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

However, this does not work. Probably the reason is the function removeClass. I am apparently using the wrong function since I want to use an identifier.

+5
source share
3 answers
$('.question_box').removeAttr('id')

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

+15
source

removeClass , class ... <div class="one two three">, .removeClass("two") , class="one three". addClass removeClass , , . id , attr.

+6

Delete class:

$('.question_box').removeClass('nameClass');

Delete id:

$('.question_box').removeAttr('id');
0
source

All Articles