1
var test = "Example";
var another = "Example";

<div id="whatever">
 Blah
</div>

$('#whatever').hide()如果testanother匹配,我该如何申请$('#whatever').css('color','red')

4

2 回答 2

3

简单的:

<script type="text/javascript">
    if(test === another){
       $('#whatever').hide();
    }else{
       $('#whatever').css('color','red');
    }
</script>
于 2012-04-18T03:39:29.863 回答
2

使用if 语句

if(test == another)
    $('#whatever').hide();
else
    $('#whatever').css('color','red');
于 2012-04-18T03:39:14.940 回答