1
I am creating a form and I want that as the option selected in the menu a different html code is shown on the screen. I’m using jquery to add the new fields. But each option selected the new fields are concatenated, that is, each time an option is selected a new value is shown, I wanted it to be shown only once. Follows the code.
$(document).ready(function() {
$( ".form-control" ).change(function(){
var varURL = $("option:selected", this).val();
$(".form-group").append('O valor selecionado é: ' + varURL);
});
});
exchange the
append
forhtml
– Wees Smith
I already tried, but the content is replaced and the options menu disappears.
– Diego Soares
then create a div inside that
form-group
just to get thehtml()
– Wees Smith
so it doesn’t delete the menu
– Wees Smith
I did it and it worked!
– Diego Soares