var test = "Example";
var another = "Example";
<div id="whatever">
Blah
</div>
如果$('#whatever').hide()
和test
匹配,我如何应用another
,如果不匹配,我如何应用$('#whatever').css('color','red')
?
答案 0 :(得分:3)
简单:
<script type="text/javascript">
if(test === another){
$('#whatever').hide();
}else{
$('#whatever').css('color','red');
}
</script>
答案 1 :(得分:2)
使用if statement:
if(test == another)
$('#whatever').hide();
else
$('#whatever').css('color','red');