开发者

jquery change font-size based on value?

I have html:

<div class="arrow-inner arrow-first arrow-border">
 CAREER <strong>1.000</strong>
</div>

Jquery:

function battingAve1000(){
    var maxBatAve = "1.000";
    var batAve = $(".arrow-first strong").html();

  开发者_运维知识库  if(maxBatAve == batAve)
        $(".arrow-first strong").css('font-size', 20);
}

But it doesn't seem to work? Not sure why, seems right...


This will work

function battingAve1000(){
var maxBatAve = "1.000";
var batAve = $(".arrow-first").find('strong').html();
console.log($(".arrow-first").find('strong').html())
if(maxBatAve == batAve)
    $(".arrow-first").find('strong').css('font-size', 20);}

But yes check out firebug for firefox and learn about console.log() to see what your vars are returning.

Actually your code does work, you just didn't call the function perhaps? See this http://jsfiddle.net/FWPd2/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜