开发者

Change <body id="grid"> to <body class="list"> with jQuery

I know how to change an id: $("body").attr('id', 'list');

But now I want to change the attribute itself; instead of id='grid' I want to have class='lis开发者_开发知识库t'

For example, this:

<body id="grid">

Should turn to:

<body class="list">


You can't really change the attribute using jQuery, but it is very easy to achieve what you want in two actions:

$("body").addClass('list').removeAttr('id');


You can do like:

$('body').removeAttr('id').attr('class', 'list');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜