how do you call a javascript function on all buttons with a class

0

I would like to call this function that is called all imput by id="inviardesb" and exchange them for all input that has <div class="classchama">

As I call this function div

<div class="buttons">
<div class="classchama">
    <input type="submit" class="button" value="Cadastrar produto" id="inviardesb">
</div>
</div>  

Live.disableDataSubmit = function() {
    $("#inviardesb").on('click', function (event) {  
    $(this).attr('disabled', true);
    $(this).parents('form').submit();
    });
}
    
asked by anonymous 24.08.2017 / 22:45

2 answers

0

In this case just change the selector, below:

<div class="buttons">
    <div class="classchama">
        <input type="submit" class="button" value="Cadastrar produto" id="inviardesb">
    </div>
</div>  

Live.disableDataSubmit = function() {
    $("div.classchama input").on('click', function (event) {  
        $(this).attr('disabled', true);
        $(this).parents('form').submit();
    });
}

The new selector is div.classchama input that detailed:

  

Select all the div tags that contains the classchama class and then search for the descendants that are a input tag

    
24.08.2017 / 22:50
0

If I understand correctly, just change #inviardesb to .inviardesb:

Live.disableDataSubmit = function() {
$(".inviardesb input").on('click', function (event) {  
    $(this).attr('disabled', true);
    $(this).parents('form').submit();
});
    
24.08.2017 / 22:50