简体   繁体   中英

Jquery/Javascript and Css condition doesn't work on firefox and IE. It works on Chrome

$('.myclassname').mouseover(function(){

  if($(this).children('span').css('font-weight')=='normal')

  {..do something... }

}

Why the "do something" works on Chrome but not on Firefox 16 and Internet Explorer 9? If I delete the if condition it works, but I need it so I can't delete. Here's the css

div.myclassname span {...; font-weight:normal ; ...}

Try,

if($(this).children('span').css('font-weight')=='400')

or

if($(this).children('span').css('font-weight')==400)

check here http://jsfiddle.net/muthkum/qpEK2/2/ font-weight return 400 in JS.

尝试这个:

if($(this).children('span').eq(0).css('font-weight')=='normal')

Can you set it up in jsfiddle? Does:

$('.myclassname').mouseover(function(){
    $('span',$(this)).each(function(){
      if($(this).css('font-weight')=='normal'){
       //do something
      }
    });
});

Work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM