Javascript examples for jQuery Method and Property:width
Set width using value returned from a function
<!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(){ $("div").width(function(n, c){ return c - 200;/*from w w w . j av a 2 s . c o m*/ }); }); }); </script> </head> <body> <button>Decrease width of div with 200 px.</button><br><br> <div style="height:100px;border:4px solid;"></div> </body> </html>