Set css value with function - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:css

Description

Set css value with function

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(){
        $("p").css("border-width", function(i){
        return i + 25;
        });/*  w ww.  j  a v  a  2 s. co  m*/
    });
});
</script>
</head>
<body>

<button>Change the border-width property of the p element</button>

<p style="border: 1px solid black;">This is a paragraph.</p>

</body>
</html>

Related Tutorials