Set two pair of attribute to an element - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:attr

Description

Set two pair of attribute to an element

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("img").attr({width: "150", height: "100"});
    });/*from   w  w w  .  j a v a  2 s.c  om*/
});
</script>
</head>
<body>

<img src="http://java2s.com/resources/a.png" alt="message" width="300" height="213"><br>

<button>Set width and height attributes of the image</button>

</body>
</html>

Related Tutorials