Exclude a tr from parents('tr')











up vote
0
down vote

favorite












I have an editable table:






    $('.table-salva').click(function() {
$(this).parents('tr').attr("contenteditable", "false");
});

$('.table-modifica').click(function() {
$(this).parents('tr').attr("contenteditable", "true");
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<div class="table-editable">
<table id="table" class="tabella text-center">
<thead>
<tr class="hide">
<th>ID</th>
<th>Data</th>
<th>Entrata</th>
<th>Uscita</th>
</tr>
</thead>
<tbody>
<tr>
<td>#</td>
<td>AAAA-MM-GG</td>
<td>00:00</td>
<td>00:00</td>
<td id="bottoni">
<span class="table-salva"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Salva</button></span>
<span class="table-modifica"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Modifica</button></span>

</td>
</tr>
</tbody>
</table>
</div>





In the table, when a user click the button "Modifica" thy can edit fields and press "Salva" to save (yeah, the buttons are disabled but after they won't).
I want that user can't edit the field "ID", how can I modify parents('tr') to exclude first of td?



EDIT: I have another question. When user click on "Modifica" he can edit value of buttons too. How can I block buttons' value editing?










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have an editable table:






        $('.table-salva').click(function() {
    $(this).parents('tr').attr("contenteditable", "false");
    });

    $('.table-modifica').click(function() {
    $(this).parents('tr').attr("contenteditable", "true");
    });

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
    <div class="table-editable">
    <table id="table" class="tabella text-center">
    <thead>
    <tr class="hide">
    <th>ID</th>
    <th>Data</th>
    <th>Entrata</th>
    <th>Uscita</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>#</td>
    <td>AAAA-MM-GG</td>
    <td>00:00</td>
    <td>00:00</td>
    <td id="bottoni">
    <span class="table-salva"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Salva</button></span>
    <span class="table-modifica"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Modifica</button></span>

    </td>
    </tr>
    </tbody>
    </table>
    </div>





    In the table, when a user click the button "Modifica" thy can edit fields and press "Salva" to save (yeah, the buttons are disabled but after they won't).
    I want that user can't edit the field "ID", how can I modify parents('tr') to exclude first of td?



    EDIT: I have another question. When user click on "Modifica" he can edit value of buttons too. How can I block buttons' value editing?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an editable table:






          $('.table-salva').click(function() {
      $(this).parents('tr').attr("contenteditable", "false");
      });

      $('.table-modifica').click(function() {
      $(this).parents('tr').attr("contenteditable", "true");
      });

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
      <div class="table-editable">
      <table id="table" class="tabella text-center">
      <thead>
      <tr class="hide">
      <th>ID</th>
      <th>Data</th>
      <th>Entrata</th>
      <th>Uscita</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>#</td>
      <td>AAAA-MM-GG</td>
      <td>00:00</td>
      <td>00:00</td>
      <td id="bottoni">
      <span class="table-salva"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Salva</button></span>
      <span class="table-modifica"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Modifica</button></span>

      </td>
      </tr>
      </tbody>
      </table>
      </div>





      In the table, when a user click the button "Modifica" thy can edit fields and press "Salva" to save (yeah, the buttons are disabled but after they won't).
      I want that user can't edit the field "ID", how can I modify parents('tr') to exclude first of td?



      EDIT: I have another question. When user click on "Modifica" he can edit value of buttons too. How can I block buttons' value editing?










      share|improve this question















      I have an editable table:






          $('.table-salva').click(function() {
      $(this).parents('tr').attr("contenteditable", "false");
      });

      $('.table-modifica').click(function() {
      $(this).parents('tr').attr("contenteditable", "true");
      });

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
      <div class="table-editable">
      <table id="table" class="tabella text-center">
      <thead>
      <tr class="hide">
      <th>ID</th>
      <th>Data</th>
      <th>Entrata</th>
      <th>Uscita</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>#</td>
      <td>AAAA-MM-GG</td>
      <td>00:00</td>
      <td>00:00</td>
      <td id="bottoni">
      <span class="table-salva"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Salva</button></span>
      <span class="table-modifica"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Modifica</button></span>

      </td>
      </tr>
      </tbody>
      </table>
      </div>





      In the table, when a user click the button "Modifica" thy can edit fields and press "Salva" to save (yeah, the buttons are disabled but after they won't).
      I want that user can't edit the field "ID", how can I modify parents('tr') to exclude first of td?



      EDIT: I have another question. When user click on "Modifica" he can edit value of buttons too. How can I block buttons' value editing?






          $('.table-salva').click(function() {
      $(this).parents('tr').attr("contenteditable", "false");
      });

      $('.table-modifica').click(function() {
      $(this).parents('tr').attr("contenteditable", "true");
      });

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
      <div class="table-editable">
      <table id="table" class="tabella text-center">
      <thead>
      <tr class="hide">
      <th>ID</th>
      <th>Data</th>
      <th>Entrata</th>
      <th>Uscita</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>#</td>
      <td>AAAA-MM-GG</td>
      <td>00:00</td>
      <td>00:00</td>
      <td id="bottoni">
      <span class="table-salva"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Salva</button></span>
      <span class="table-modifica"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Modifica</button></span>

      </td>
      </tr>
      </tbody>
      </table>
      </div>





          $('.table-salva').click(function() {
      $(this).parents('tr').attr("contenteditable", "false");
      });

      $('.table-modifica').click(function() {
      $(this).parents('tr').attr("contenteditable", "true");
      });

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
      <div class="table-editable">
      <table id="table" class="tabella text-center">
      <thead>
      <tr class="hide">
      <th>ID</th>
      <th>Data</th>
      <th>Entrata</th>
      <th>Uscita</th>
      </tr>
      </thead>
      <tbody>
      <tr>
      <td>#</td>
      <td>AAAA-MM-GG</td>
      <td>00:00</td>
      <td>00:00</td>
      <td id="bottoni">
      <span class="table-salva"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Salva</button></span>
      <span class="table-modifica"><button disabled type="button" class="btn btn-danger btn-rounded btn-sm my-0">Modifica</button></span>

      </td>
      </tr>
      </tbody>
      </table>
      </div>






      jquery html-table bootstrap-4






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 21:08









      Brian Tompsett - 汤莱恩

      4,153133699




      4,153133699










      asked Nov 10 at 20:50









      SlaaSh

      434




      434
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I also suspect you don't want the buttons editable either



          You could make the applicable <td>s the target using:



          $(this).parent().siblings().not(':first').attr(...





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243277%2fexclude-a-tr-from-parentstr%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            I also suspect you don't want the buttons editable either



            You could make the applicable <td>s the target using:



            $(this).parent().siblings().not(':first').attr(...





            share|improve this answer

























              up vote
              0
              down vote













              I also suspect you don't want the buttons editable either



              You could make the applicable <td>s the target using:



              $(this).parent().siblings().not(':first').attr(...





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                I also suspect you don't want the buttons editable either



                You could make the applicable <td>s the target using:



                $(this).parent().siblings().not(':first').attr(...





                share|improve this answer












                I also suspect you don't want the buttons editable either



                You could make the applicable <td>s the target using:



                $(this).parent().siblings().not(':first').attr(...






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 21:04









                charlietfl

                137k1285118




                137k1285118






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243277%2fexclude-a-tr-from-parentstr%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Danny Elfman

                    Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues