To change the value of an attribute in JavaScript, you can try to run the following code −
Example
<!DOCTYPE html>
<html>
<body>
<img id="HTML5" src="https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg" width="200" height="150">
<script>
document.getElementById("HTML5").width = "250";
</script>
<p>Image width updated</p>
</body>
</html>