appending and removing content with jquery

I dont think I am using the .remove correctly because instead of "info about canada" being removed from the div "info", it is stacked on top of "info about russia" instead.

js

if (code == 'ca') {
        $('#info').append('<p class="i">info about canada</p>');
    } else if (code == 'ru') {
    $('#info').remove('.i');
        $('#info').append('<p class="i">info about russia</p>');
    }

html

<div id="info">
<h3>Info</h3>
</div>

Answers


If you are trying to replace the contents of #info then don't use remove, empty, or append, just use html:

$('#info').html('<p class="i">info about russia</p>');

Need Your Help

getting value from other column besides the valuemember column in Infragistics ultracombo

vb.net visual-studio combobox infragistics ultracombo

I am fairly new to using infragistics controls (started yesterday). While they are (very) impressive they do add another layer of complexity, which I am muddeling through. So I am asking what I fee...