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');
});
}
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>