Get style value

Description

The following code shows how to change left value when clicking.

Example


<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div {<!--from   www .  j  a va  2s . c  o m-->
  position: absolute;
  left: 10px;
  top: 10px;
  width: 20px;
  height: 20px;
  background-color: green;
}
</style>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(function() {

    $(document).click(function() {
      var pos = $("div").css("left");
      pos = parseInt(pos);
      $("div").css("left", pos + 10);
    });
  });
</script>
</head>
<body>
  <div></div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities