I would like to make the sum of fields that I add in the page via ajax. I would like to make this sum on load the page after add the fields, I know the method I should use is live(), but I do not know how.
$("i don't know what: body, document?").live("what event?", function(){
somaTudo();
});
function somatorio(colecao, destino){
var totalHora = 0;
colecao.each(function(){
if(this.value!=""){
totalHora += parseFloat(this.value);
}
});
destino.val(totalHora);
}
function somaTudo(){
$("[name^=total]").each(function(){
var $this = $(this);
somatorio($("[quadro=" + $this.attr("quadro") + "]"), $("#total" + $this.attr("quadro")));
});
}
Anyone can help me?