0

I'm attempting to run a split test with Optimizely and need to increase the size of the font that is used as description text in my site search's search field.

I've managed to change the color using this code:

$("input[value]").css({"color":"#cc0000"});

But if I add on font-size to this nothing happens? i.e.

$("input[value]").css({"color":"#cc0000", "font-size" : "1.9rem"});

I've also tried the following but it still doesn't seem to work??

$("input").css({"font-size" : "1.9rem"});
bbacarat
  • 253
  • 1
  • 4
  • 16

4 Answers4

4

It looks like you have !important over riding the changes made using .css() function. So do the following.

$("input")
    .css({
        'cssText':'font-size:1.9rem !important',
        'color':'#cc0000'
    });

DEMO

rrk
  • 15,677
  • 4
  • 29
  • 45
1

Try do it like this:

var fontSize = parseInt($("input").css("font-size"));
fontSize = fontSize + 1 + "px";
$("input").css({'font-size':fontSize});

or

var fontSize = $('input').css('font-size').split('px')[0];

var fontInt = parseInt(fontSize) + 1;

fontSize = fontInt + 'px';
Barr J
  • 10,636
  • 1
  • 28
  • 46
0

I have provided a jsFiddle which will hopefully be the answer you are looking for

https://jsfiddle.net/07x2trL9/1/

Html

<input style="font-size:15px" class="big-font" type="text" />

Javascript/jQuery

$(function () {
    $('.big-font').css("font-size", "25px");
});

You simply target your input and change the size like so

Canvas
  • 5,779
  • 9
  • 55
  • 98
0

Is this just a typo? try

$("input").css({"font-size" : "1.9em"});

'em' instead of 'rem'

Colm Ryan
  • 1,208
  • 2
  • 14
  • 12
  • @Colm Ryan, thanks for replying but this didn't change anything. – bbacarat Jul 27 '15 at 11:57
  • Maybe I've misunderstood the question, I set up a fiddle here https://jsfiddle.net/gajy3x3k/1/ and I definitely see the text size change. Also I was completely wrong about 'rem', though it may not work with all browsers. – Colm Ryan Jul 27 '15 at 12:07