如何在struts 2中使用jquery autocomplete和多个标记 我在struts2的jQuery中使用了多个标记它和自动完成的例子。但是它不起作用。我没有使用struts自动完成标记。 $(函数(){ $('#tags input')。on('focusout',function(){ var txt=this.value.replace(//[^a-zA-Z0-9\+-\.\\.\\\.\\\\.\\\\]/g',);//允许的字符 如果(txt){ $(this).before(“”+txt.toLowerCase()+“”); } 此。值=”; }).on('keyup',功能(e){ //如果:逗号,则输入(用|管道分隔更多键码) if(/(188 | 13)/.test(e.which))$(this.focusout(); }); $('#tags')。在('单击','.tag',函数()上{ 如果(确认(“是否真的删除此标记?”)$(此).remove(); }); }); jQuery(函数(){ $(“#mytag”).autocomplete(“list.jsp”); }); //htlm输入文本标记------

如何在struts 2中使用jquery autocomplete和多个标记 我在struts2的jQuery中使用了多个标记它和自动完成的例子。但是它不起作用。我没有使用struts自动完成标记。 $(函数(){ $('#tags input')。on('focusout',function(){ var txt=this.value.replace(//[^a-zA-Z0-9\+-\.\\.\\\.\\\\.\\\\]/g',);//允许的字符 如果(txt){ $(this).before(“”+txt.toLowerCase()+“”); } 此。值=”; }).on('keyup',功能(e){ //如果:逗号,则输入(用|管道分隔更多键码) if(/(188 | 13)/.test(e.which))$(this.focusout(); }); $('#tags')。在('单击','.tag',函数()上{ 如果(确认(“是否真的删除此标记?”)$(此).remove(); }); }); jQuery(函数(){ $(“#mytag”).autocomplete(“list.jsp”); }); //htlm输入文本标记------,jquery,struts2,autocomplete,tag-it,Jquery,Struts2,Autocomplete,Tag It,这是一个带有标记和自动完成的工作示例。查看它,了解它的工作原理,确保使用最新的库并根据您的需要进行自定义: HTML <script src="js/jquery.autocomplete.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="JS/jquery-1.4.2.

这是一个带有标记和自动完成的工作示例。查看它,了解它的工作原理,确保使用最新的库并根据您的需要进行自定义:

HTML

<script src="js/jquery.autocomplete.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="JS/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
 $('#tags input').on('focusout',function(){ 
var txt= this.value.replace(/[^a-zA-Z0-9\+\-\.\#]/g,'');//allowed characters
if(txt) {
$(this).before('<span class="tag">'+txt.toLowerCase()+'</span>');
}
this.value="";
}).on('keyup',function(e){
// if: comma,enter(delimit more keyCodes with | pipe)
if(/(188|13)/.test(e.which))$(this).focusout();
});
 $('#tags').on('click','.tag',function(){
if(confirm("Really delete this tag?"))$(this).remove();
 });
});
</script>
<script type="text/javascript">
jQuery(function(){
$("#mytag").autocomplete("list.jsp");
});
</script>
<!-- tsk -->
//htlm input text tag------
 <div id="tags">
<input type="text" value="" placeholder="Add a tag" id="mytag" />
 </div>
<ul id="mytags" >

</ul>
$("#mytags").tagit({
    autocomplete: { source: function( request, response ) {
        $.ajax({
            url: "http://ws.geonames.org/searchJSON?username=foobar",
            dataType: "jsonp",
            data: {
                featureClass: "P",
                style: "full",
                maxRows: 12,
                name_startsWith: request.term
            },
            success: function( data ) {
                response( $.map( data.geonames, function( item ) {
                    return {
                        label: item.name + (item.adminName1 ? ", " 
                             + item.adminName1 : "") + ", " + item.countryName,
                        value: item.name
                    }
                }));
            }
        });
    }, minLength: 2 }
});