<input id="img" type="file" name="img" accept="image/*">
And this is the JQuery code:
$('#img').change(function(){
if($('#this').val() === '') {
$("#subm").remove();
} else {
$('<button id="subm" type="submit">Press</button>').insertAfter('#advice');
}
});
I'm trying check if the input file is empty, if is empty, and exist a button called subm, I delete it, but if the input file has a file, I create that bottom. The problem is that, if there's a submbotton, because I select file, and after I change the input, let it empty, JQuery doesn't delete it.
How can I delete a button, created by JQuery, if an input file is empty?
Thank's advance!