CodeLab
Show Output
 
 
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8">
5
<title>jQuery css()</title>
6
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
7
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
8
<script>
9
$(document).ready(function() {
10
  $("#button").click(function() {
11
     alert("Font Size is : " + $("p").css("font-size"));
12
  });
13
});
14
</script>
15
</head>
16
<body>
17
 <p style="font-size:18px">lorem ipsum dolor sit</p>
18
 <button style="margin:0 0 10px 0;background:#e8e8e8;" class="btn" id="button">Click here to get a font size of first matched element</button><br />
19
 </body>
20
</html>                            
 

Share this example with Facebook, Twitter