JQueryオートコンプリートフィールドがあり、そこから複数の要素を(順番に)選択し、後で取得できるようにそれらをdivに配置します。これはすべて機能します。問題は、すでに選択した要素を選択した場合、それをdivに表示したくないということです。私がこれまでに持っているコードはcontainssearchを実行しますが、完全に一致する必要があります。これを行うために次のコードを変更するにはどうすればよいですか?
<script type="text/javascript">
            $(function () {
                function locationLog(message) {
                    if (!$('#locationLog div:contains(' + message + ')').length) {
                        $("<div/>").text(message).appendTo("#locationLog");
                        $("<br/>").text("").appendTo("#locationLog");
                        $("#locationLog").scrollTop(0);
                    }
                }
                $("#Location").autocomplete({
                    source: "/Results/GetLocations",
                    minLength: 1,
                    select: function (event, ui) {
                        if (ui.item != null)
                            locationLog(ui.item.value);
                    }
                });
            });
       </script>