从jquery-ui可排序列表中获取值

时间:2019-02-01 13:13:13

标签: jquery-ui-sortable

我试图在对值进行排序后从sortablejs列表中获取值。想法是对照正确的单词顺序检查排序的单词顺序。 我的html是:

 <ul id = "scrambled">
     <li id = "1" class = "default">I</li>
     <li id = "2" class = "default">write</li>
     <li id = "3" class = "default">can't</li>
     <li id = "4" class = "default">jquery</li>
     <li id = "5" class = "default">proper</li>
     <li id ="btn1"><button  onclick="checkOrd();">Check</button></li>
  </ul>
  <br>
  <h3><span id = "word_order"></span></h3>

我的脚本是:

      <script>
      //make the list sortable
     $(function makeSort() {
    $( "#scrambled" ).sortable({

    });

    $( "#scrambled" ).disableSelection();

   });

    //get word order on button click     

        function getOrder() {
            var ans = $('#scrambled').text().replace(/(\r\n|\n|\r)/gm, " ");
                if (ans == "I can't compile proper jquery")
                    alert("You'd better learn.")
                else
                    alert("You got " + ans)
};
</script>

给我“你不知道我是否可以编译properjquery”,所以间距完全乱七八糟。我该如何纠正自己所做的事情?

0 个答案:

没有答案