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?
jquery html-table bootstrap-4
add a comment |
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?
jquery html-table bootstrap-4
add a comment |
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?
jquery html-table bootstrap-4
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
jquery html-table bootstrap-4
edited Nov 10 at 21:08
Brian Tompsett - 汤莱恩
4,153133699
4,153133699
asked Nov 10 at 20:50
SlaaSh
474
474
add a comment |
add a comment |
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(...
add a comment |
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(...
add a comment |
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(...
add a comment |
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(...
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(...
answered Nov 10 at 21:04
charlietfl
136k1285118
136k1285118
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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