0

I would like to know if there is a way to increase the value of a css attribute when a button is clicked.

For example the css would be

.Testclass{
font-size:30px;
}

is there a way to increase the number in that css attribute by 10 every time the button is click either suing js or jquery.

Jessie
  • 1
  • 3

1 Answers1

0

Try this code below...

EDIT (see comments below): Put this into the function

 var p = parent_window.document.body;
 var size = $('#teleprompter',p).css('font-size').slice(0,-2);
 size-=10;
 $('#teleprompter',p).css('font-size',size+'px');

Other snippet (old):

$('button[name=btn]').click(function(){
  var size = $('.Testclass').css('font-size').slice(0,-2);
  size -=10;
  $('.Testclass').css('font-size',size+'px')
  });
.Testclass{
font-size:30px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button name="btn">Make the font-size smaller!</button><div class="Testclass">TEXT</div>

Greetings from Austria

Bernd
  • 730
  • 1
  • 5
  • 13