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
Published on 26-Feb-2018 15:29:25
Advertisements