Answer the question
In order to leave comments, you need to log in
How to add styles for SPAN through JS?
Hello, I specifically need help here, the implementation does not come to mind.
Fiddle: jsfiddle.net/webirus/yfjqp49q
<span class="span20">Размер шрифта 20 пикселей</span><br>
<span class="span26">Размер шрифта 26 пикселей</span><br>
<span class="span40">Размер шрифта 40 пикселей</span><br>
<span class="span14">Размер шрифта 14 пикселей</span>
.span14 {font-size: 14px;}
.span20 {font-size: 20px;}
.span21 {font-size: 21px;}
.span22 {font-size: 22px;}
.span23 {font-size: 23px;}
.span24 {font-size: 24px;}
.span25 {font-size: 25px;}
.span26 {font-size: 26px;}
.span40 {font-size: 40px;}
Answer the question
In order to leave comments, you need to log in
$('span').each(function(){
var font_size = $(this).attr('class');
font_size = font_size.replace(/\D/g, '') + 'px';
$(this).css('font-size', font_size);
})
$('.span').attr("style","font-size: 20px;) or simply by adding and removing the class .addClass .removeClass
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question