I'm trying to insertAfter a span element when select another ID to hide other elements.
But the problem is when I have selected an ID once, it inserts a span element. Then when I select another ID, it should hide inserted span element, but it doesn't.
Later on, when I select again same ID, it insertsAfter another span element. That second element later works with the hide code, but first inserted element doesn't.
It adds #omniva double elemnt, and hides only one of it
<script>
$("#flat").click(function(){
$("#show-lp24-select").hide();
$("#show-omniva24-select").hide();
$("#text-area-comment").show();
});
$("#lp24").click(function(){
$("#text-area-comment").hide();
$("#show-omniva24-select").hide();
$("#show-lp24-select").insertAfter( $( "#lp24" ) ).show();
});
$("#button-shipping-method").click(function(){
var selectBoxVal = $("#select-box-lp24").val(); //VALUE OF SELECT BOX
$("#shipping-method-place").val("LP 24/7 terminalo adresas - "+selectBoxVal);
});
$("#omniva").click(function(){
$("#show-lp24-select").hide();
$("#text-area-comment").hide();
$("#show-omniva24-select").insertAfter( $( "#omniva" ) ).show();
});
$("#button-shipping-method").click(function(){
var selectBoxVal = $("#select-box-omniva24").val(); //VALUE OF SELECT BOX
$("#shipping-method-place").val("Omniva 24/7 terminalo adresas - "+selectBoxVal);
});
</script>

Three concepts below:
.on()for your event handlers.Have a close look at the voluntarly uncommented changes. And if that fails... Please have a look at the console.
...would translate into "After a page refresh" or "days after"... How would one know? ;)