Created
June 18, 2011 11:03
jquery sans backbone
This file contains 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() { | |
var suite= new Array; | |
var cumul=0; | |
var nb=0; | |
$('#nombre_element').text(nb); | |
$('#cumul_element').text(cumul); | |
$('#add_element').click(function() { | |
var input = $('#new-element').val(); | |
cumul+= Number(input); | |
nb+=1; | |
$('#nombre_element').text(nb); | |
$('#cumul_element').text(cumul); | |
$('#suite').append("<span id=c"+ nb+ "> " + input +" </span>"); | |
suite[nb-1]= input; | |
}); | |
$('#supp_element').click(function() { | |
var tmp= suite[suite.length-1]; | |
cumul -= tmp; | |
var tmpspan="#c"+ nb; | |
nb-=1; | |
$('#nombre_element').text(nb); | |
$('#cumul_element').text(cumul); | |
$(tmpspan).remove(); | |
suite =suite.slice(0,nb) ; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment