可以指定按钮触发事件插件jquery.dragsort.js

      发布在:前端技术      评论:0 条评论
<pre style="background-color:#262e37;color:#ffffff;font-family:&#39;Consolas&#39;,monospace;font-size:11.3pt;">&lt;<span style="color:#c32867;font-weight:bold;">div </span><span style="color:#a6e22e;">class</span><span style="color:#e6db74;font-weight:bold;">=&quot;wrap&quot;</span>&gt;<br/> &lt;<span style="color:#c32867;font-weight:bold;">div</span>&gt;&lt;<span style="color:#c32867;font-weight:bold;">input </span><span style="color:#a6e22e;">type</span><span style="color:#e6db74;font-weight:bold;">=&quot;text&quot; </span><span style="color:#a6e22e;">value</span><span style="color:#e6db74;font-weight:bold;">=&quot;1&quot;</span>&gt;&lt;<span style="color:#c32867;font-weight:bold;">button </span><span style="color:#a6e22e;">class</span><span style="color:#e6db74;font-weight:bold;">=&quot;btn-dragsort&quot;</span>&gt;<b>拖动</b>&lt;/<span style="color:#c32867;font-weight:bold;">button</span>&gt;&lt;/<span style="color:#c32867;font-weight:bold;">div</span>&gt;<br/> &lt;<span style="color:#c32867;font-weight:bold;">div</span>&gt;&lt;<span style="color:#c32867;font-weight:bold;">input </span><span style="color:#a6e22e;">type</span><span style="color:#e6db74;font-weight:bold;">=&quot;text&quot; </span><span style="color:#a6e22e;">value</span><span style="color:#e6db74;font-weight:bold;">=&quot;2&quot;</span>&gt;&lt;<span style="color:#c32867;font-weight:bold;">button </span><span style="color:#a6e22e;">class</span><span style="color:#e6db74;font-weight:bold;">=&quot;btn-dragsort&quot;</span>&gt;<span style="font-weight:bold;">拖动</span>&lt;/<span style="color:#c32867;font-weight:bold;">button</span>&gt;&lt;/<span style="color:#c32867;font-weight:bold;">div</span>&gt;<br/> &lt;<span style="color:#c32867;font-weight:bold;">div</span>&gt;&lt;<span style="color:#c32867;font-weight:bold;">input </span><span style="color:#a6e22e;">type</span><span style="color:#e6db74;font-weight:bold;">=&quot;text&quot; </span><span style="color:#a6e22e;">value</span><span style="color:#e6db74;font-weight:bold;">=&quot;3&quot;</span>&gt;&lt;<span style="color:#c32867;font-weight:bold;">button </span><span style="color:#a6e22e;">class</span><span style="color:#e6db74;font-weight:bold;">=&quot;btn-dragsort&quot;</span>&gt;<span style="font-weight:bold;">拖动</span>&lt;/<span style="color:#c32867;font-weight:bold;">button</span>&gt;&lt;/<span style="color:#c32867;font-weight:bold;">div</span>&gt;<br/>&lt;/<span style="color:#c32867;font-weight:bold;">div</span>&gt;</pre><pre style="background-color:#262e37;color:#ffffff;font-family:&#39;Consolas&#39;,monospace;font-size:11.3pt;"><span style="color:#660e7a;font-weight:bold;font-style:italic;">$</span>(<span style="color:#e6db74;">&#39;</span><span style="color:#e6db74;background-color:#191f26;">.wrap</span><span style="color:#e6db74;">&#39;</span>).<span style="color:#4ac60a;">dragsort</span>({<br/> <span style="color:#660e7a;font-weight:bold;">drop_exchange</span><span style="color:#f92672;">:</span><span style="color:#ae81ff;">0</span>,<br/> <span style="color:#660e7a;font-weight:bold;">itemSelector</span><span style="color:#f92672;">: </span><span style="color:#e6db74;">&#39;div&#39;</span>, <span style="color:#5b7773;background-color:#191f26;">//</span><span style="color:#5b7773;background-color:#191f26;font-family:&#39;宋体&#39;,monospace;">可拖动的块</span><span style="color:#5b7773;font-family:&#39;宋体&#39;,monospace;"><br/></span><span style="color:#5b7773;font-family:&#39;宋体&#39;,monospace;"> &nbsp; &nbsp; </span><span style="color:#660e7a;font-weight:bold;">dragSelector</span><span style="color:#f92672;">: </span><span style="color:#e6db74;">&quot;.btn-dragsort&quot;</span>, <span style="color:#5b7773;background-color:#191f26;">//</span><span style="color:#5b7773;background-color:#191f26;font-family:&#39;宋体&#39;,monospace;">可以触发拖动事件的选择器</span><span style="color:#5b7773;font-family:&#39;宋体&#39;,monospace;"><br/></span><span style="color:#5b7773;font-family:&#39;宋体&#39;,monospace;"> &nbsp; &nbsp;</span><span style="color:#4ac60a;">dragEnd</span><span style="color:#f92672;">: function </span>(<span style="color:#fd971f;font-style:italic;">item</span>) {<br/> <span style="color:#5b7773;background-color:#191f26;">//</span><span style="color:#5b7773;background-color:#191f26;font-family:&#39;宋体&#39;,monospace;">拖到完触发的事件</span><span style="color:#5b7773;font-family:&#39;宋体&#39;,monospace;"><br/></span><span style="color:#5b7773;font-family:&#39;宋体&#39;,monospace;"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color:#5b7773;background-color:#191f26;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(&#39;drop!&#39;,item);</span><span style="color:#5b7773;"><br/></span><span style="color:#5b7773;"> &nbsp; &nbsp;</span>},<br/>});</pre><p>更多参考:https://www.jqueryscript.net/other/Drag-To-Sort-Plugin-jQuery-dragSort.html</p>
相关文章
热门推荐