Created
January 6, 2018 01:42
-
-
Save rg3915/d18399b3fbbd2ba72d8367bdb5dea415 to your computer and use it in GitHub Desktop.
Percorrendo todos os tr de uma tabela e identificando o último elemento, e transformando a tabela em campos editáveis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
// Edit money | |
$('.money-edit').on('click', function() { | |
let obj = $(this).closest('tr').children('td') | |
// get the length of array (obj) | |
let totalLen = obj.length | |
obj.each(function(i, e) { | |
var item_v = $(this).text() | |
if (i < totalLen - 1) { | |
$(this).empty() | |
$(this).append('<input type="text" style="width:7em" value="' + item_v + '" />') | |
} | |
}); | |
}); | |
// Delete money | |
$('.money-delete').on('click', function() { | |
let url = $(this).data('url') | |
let $this = $(this) | |
$.get(url, function(data) { | |
$this.parent().parent().remove() | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment