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.

0

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

15 Comments

would it matter if the actual css is in a separate file?
Oh i believe this could be a problem...
is there a work around for that
So i've tried it with an external CSS and it also works... show me your code (html + jscript)
can i link you to a zip of my code?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.