Test
First script
HTML
<body>
<p id="one">One</p>
<p id="two">Two</p>
<p id="three">Three</p>
<p id="four">Four</p>
<p>
<button onclick="changeId()">Try it</button>
</p>
</body>
CSS
#one {
color: red;
}
#two {
color: blue;
}
JavaScript
function changeId() {
var el = document.getElementById('one');
el.id = 'two';
}