How to use width() Method in JQuery

In this article, I will explain use of width () Method in JQuery.
  • 1738

JQuery CSS width() Method

  • width () method method set and return the height of selected elements.

Syntax

$(selector).width()

Example

The following example shows how to width() method in jquery.

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("button").click(function () {

            alert("Width is "+$("p").width());

        });

    });

</script>

</head>

<body>

<p>width() Method Example</p>

<button>Click for Get the width</button>

</body>

</html>

 

Output


width simple.jpg

Further Readings

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.