views:

99

answers:

2

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='list'

For example, this:

<body id="grid">

Should turn to:

<body class="list">
+2  A: 

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');
Kobi
+1  A: 

You can do like:

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