Here the function is working but the color on the
<p>
is does not stay for longer time as soon as i leave the button if comes to its original form
function color(){
document.getElementById("change").style.color = "#ff00ff";
}
<p id="change"></p>
<button onclick="color()">Change</button>
works perfectly at mine, but try this
document.getElementById('button_id').addEventListener('click', color)