如果javacript中的声明不起作用 [英] If statement in javacript not working

查看:59
本文介绍了如果javacript中的声明不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我想要一个按钮,我必须在没有图像显示时被禁用。它第一次工作,但任何其他时间没有图像,它不会禁用按钮。我有另一个按钮,它附有滚动功能,因此当它被执行时,它会生成图像。在每一轮之后,图像消失,所以我应该禁用其他按钮。



Okay so I want a button i have to be disabled when there are no images displaying. it works the first time but any other time there are no images it does not disable the button. I have another button that has the roll function attached to it so when it is executed it generates images . after each round the images disappear so the other button i have should be disabled .

function roll(die,i){

       rando = Math.floor(Math.random()*6)+1;

        die.html("<img  src=images/die"+rando+".png>");
         die.find('img').attr('class', rando);

         dice_value[i]=rando;

      $('img').height(50);


   };

if($('img').length==0){
  $('.button2').prop('disabled',true);
}





我尝试过:



我试过使用这个if语句



What I have tried:

ive tried using this if statement

推荐答案

' < span class =code-string> img')。height( 50 );


};

if
('img').height(50); }; if(


'' img')。length == 0 ){
('img').length==0){


' 。button2')。prop(' disabled' true );
}
('.button2').prop('disabled',true); }





我尝试过:



我试过使用这个if语句



What I have tried:

ive tried using this if statement


这篇关于如果javacript中的声明不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆