<!DOCTYPE html>
<html>
<head>
<title>jQuery attr() function</title>
<script src="jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("button").click(function(){
$("p").attr("style","text-align: center");
});
});
</script>
</head>
<body>
<div>
<p>Heading</p>
<button>Set attribute value</button>
</div>
</body>
</html>