Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jqueryselect2标记_Javascript_Jquery_Jquery Select2 - Fatal编程技术网

Javascript jqueryselect2标记

Javascript jqueryselect2标记,javascript,jquery,jquery-select2,Javascript,Jquery,Jquery Select2,如何使用javascript或jquery获取特定的已删除标记。我从Select元素中选择所有内容,并使用array_diff在服务器端分离标记,我只想直接获得已删除的标记这是我的代码 <script> $(document).ready(function(){ $("#e23").select2({ tags:[], dropdownCss: {dis

如何使用javascript或jquery获取特定的已删除标记。我从Select元素中选择所有内容,并使用array_diff在服务器端分离标记,我只想直接获得已删除的标记这是我的代码

  <script>
           $(document).ready(function(){
               $("#e23").select2({
                   tags:[],
                   dropdownCss: {display: 'none'},
                   tokenSeparators: [" "],
                   maximumInputLength: 10
                   });
            var x =$("#e23").val();
            $("#e23").on("change", function() {var as=($("#e23").val());
            $.ajax({
                url: "http://localhost/healthkatta/index.php?r=jdashboard/Demo/create",//this is the request page of ajax
                data: {
                    //special:specialisation,
                    name1   :x,
                    name2  :as,
                },//data for throwing the expected url
                type:"GET",//you can also use GET method
                dataType:"html",//you can also specify for the result for json or xml
                success:function(response){
                        $('.log').html(response);
                 },
                error:function(){
                    //TODO: Display in the poll tr ifself on error   
                    alert("Failed request data from ajax page"); 
                }
            });});
                 });
        </script>

    <body>


    <strong>Default Keywords</strong>
    <br>
    <br>
    <div class="log"></div>
    <input id="e23" class="select2-offscreen" type="hidden" value="<?php for($i=0;$i<count($result);$i++){ 
        if ($i == count($result)-1)
            echo $result[$i]->keyword->keyword;      
        else
           echo $result[$i]->keyword->keyword.',';
    }?>"style="width:500px" tabindex="-1">
    <div id="dialog-form" title="Add Custom Keywords">
     <form>
      <fieldset>
        <label for="name">Keyword</label>
        <input type="hidden" name="name" id="name" class="text ui-widget-content ui-corner-all" />
     </fieldset>
     </form>
    </div>
    <br>
    <br>
    <button id="create-user">Add More</button>

    </body>

试试这样的

.on("change", function(e) {
    if(typeof e.added != 'undefined'){
        // ID OF ADDED ELEMENT
        var added_id = e.added.id;
    }else if(typeof e.removed != 'undefined'){
        // ID OF REMOVED ELEMENT
        var removed_id = e.removed.id;
    }
});

谢谢@rajesh kakawat的回复,我会试试的