Last active
August 29, 2015 14:04
-
-
Save jonasporto/9b385d705f3ff12a9ebc to your computer and use it in GitHub Desktop.
adicionando eventos a elementos criados por append
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
$(document).on('click','.add-option',function(){ | |
$(this).removeClass('add-option btn-success').addClass('rm-option btn-danger').text('-'); | |
option_input = "<input type=\"text\" class=\"options\" placeholder=\"Digite uma opção\" /><button class=\"add-option btn btn-success\" type=\"button\">+</button>"; | |
$('.option').append(option_input); | |
}).on('click', '.rm-option', function(){ | |
$(this).prev().remove(); | |
$(this).remove(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment