jquery css() 增加值

2021-02-19 豬豬美食世界

<!DOCTYPE html>

<title>My Example</title>

<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">

</script>

<script>

  $( function() {

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

      $( this ).css( {

       "background": "gold",

       "font-size": "+=1.5em",

       "padding": "+=10" 

      } );   

    });

  });

</script>

<p>Click me.</p>

<p>Using jQuery relative values such as <code>+=1.5em</code> adds that amount to the current value.</p>

<p>Clicking the element continuously will result in the value being incremented continuously.</p>

相關焦點