I'm trying to adjust title sizes depending on character length. (wordpress)
This is what I have so far. It doesn't return any error but it doesn't work.
jQuery(function ($) {
$(window).load(function () {
var textLength = $('.autotitle').val().length;
if (textLength < 20) {
// Do noting
} else if (textLength > 20) {
$('.autotitle').css('font-size', '16px');
}
});
});
.autotitle? If it's notinputtry.html()instead of.val()but note that it may include inner tags and whitespaces. - Viktor BahtevcodejQuery(function ($) { $(window).load(function() { var textLength = $(".autotitle").val().length; if(textLength < 20) { $(".autotitle").css('font-size', '12px'); } }); });code- Juárez