jquery needing simplifcation
<p>I am fairly new to jquery and I've been trying to work out how to bind correctly. I'm trying to make this a little simpler as it seems to be a bit long winded since I've had to basically put everything twice.</p>

<p>Any help would be great!</p>

<pre><code>$("#btn-add").click(function(){
    $("#genre option:selected").each(function(){
        $("#display_genre").append("&lt;li id='dg_"+$(this).val()+"'&gt; "+$(this).text()+" &lt;a class='btn-remove' href='JavaScript:void(0);' name='"+$(this).val()+"'&gt;&lt;img border='0' src='images/delete.png'&gt;&lt;/a&gt;&lt;/li&gt; ");
        $("#selected").val($("#selected").val()+$(this).val()+',');
        $(this).remove();
        $(".btn-remove").bind("click", function(){
            var get_value = $(this).attr("name");
            var get_genre = $("#dg_"+get_value).text();
            $("#genre").append($("&lt;option/&gt;").attr("value", get_value).text(get_genre)); 
            $("#selected").val($("#selected").val().replace(get_value+',',''));
            $("#dg_"+get_value).remove();
            var sort_options = $.makeArray($("#genre option")).sort(function (a, b){
                return a.text == b.text ? 0 : a.text &lt; b.text ? -1 : 1;
            });
            $("#genre").html(sort_options);
        });
    });
});
$(".btn-remove").click(function(){
    var get_value = $(this).attr("name");
    var get_genre = $("#dg_"+get_value).text();
    $("#genre").append($("&lt;option/&gt;").attr("value", get_value).text(get_genre)); 
    $("#selected").val($("#selected").val().replace(get_value+',',''));
    $("#dg_"+get_value).remove();
    var sort_options = $.makeArray($("#genre option")).sort(function (a, b){
        return a.text == b.text ? 0 : a.text &lt; b.text ? -1 : 1;
        $("#btn-add").bind("click", function(){
            $("#genre option:selected").each(function(){
                $("#display_genre").append("&lt;li id='dg_"+$(this).val()+"'&gt; "+$(this).text()+" &lt;a class='btn-remove' href='JavaScript:void(0);' name='"+$(this).val()+"'&gt;&lt;img border='0' src='images/delete.png'&gt;&lt;/a&gt;&lt;/li&gt; ");
                $("#selected").val($("#selected").val()+$(this).val()+',');
                $(this).remove();
            });
            $("#genre").html(sort_options);
        });
    });
});
</code></pre>
