weixin_33739523 2018-11-27 00:13 采纳率: 0%
浏览 34

显示的照片

How do I disable the submit button once the photos is displayed on the page? Anyone knows? Here's my code:

        if("#pic" == true){
         }
         else{
           $("#submit").click(function () {           
           var button = $(this);
           button.attr('disabled', 'disabled');           
          });

        }
  • 写回答

1条回答 默认 最新

  • weixin_33695082 2018-11-27 05:04
    关注

    here's the modified code

    $('#pic').on('load', function() {
      console.log("loaded");
      
      $('#submit').attr('disabled',true);
    })
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <img id="pic" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" />
    
    <button id="submit">hello</button>

    if the img source is improper it won't render and the load method is hence not called, so we are sure of the proper image source and after rendering it calls the Load method in which you can disable your button

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 无法输出helloworld
  • ¥15 高通uboot 打印ubi init err 22
  • ¥20 PDF元数据中的XMP媒体管理属性
  • ¥15 R语言中lasso回归报错
  • ¥15 网站突然不能访问了,上午还好好的
  • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
  • ¥15 semrush,SEO,内嵌网站,api
  • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
  • ¥15 振荡电路,ADS仿真
  • ¥15 关于#c语言#的问题,请各位专家解答!