How to change the value of an attribute in javascript?

JavascriptWeb DevelopmentFront End Scripts

To change the value of an attribute in JavaScript, you can try to run the following code −

Example

Live Demo

<!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>
raja
Updated on 23-Jun-2020 09:07:18

Advertisements