how to toggle attr() in jquery

前端 未结 10 1929
独厮守ぢ
独厮守ぢ 2021-01-30 15:50

I have a simple add attribute function:

$(\".list-toggle\").click(function() {
    $(\".list-sort\").attr(\'colspan\', 6);
});

My question is:

10条回答
  •  时光说笑
    2021-01-30 16:25

    For readonly/disabled and other attributes with true/false values

    $(':submit').attr('disabled', function(_, attr){ return !attr});
    

提交回复
热议问题