Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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 select元素中的可排序本机选项_Javascript_Jquery_Html_Jquery Ui - Fatal编程技术网

Javascript select元素中的可排序本机选项

Javascript select元素中的可排序本机选项,javascript,jquery,html,jquery-ui,Javascript,Jquery,Html,Jquery Ui,使用jQuery/jQuery UI是否可以使选择节点的选项节点可排序 这将允许用户按照他们想要的顺序拖动选项 例如: <select id="foo"> <option>1</option> <option>2</option> <option>3</option> </select> 1. 2. 3. 您可以订购它们1、2、3或1、3、2或2、3、1等。无论如何在Fi

使用jQuery/jQuery UI是否可以使选择节点的选项节点可排序

这将允许用户按照他们想要的顺序拖动选项

例如:

<select id="foo">
    <option>1</option>
    <option>2</option>
    <option>3</option>
</select>

1.
2.
3.

您可以订购它们1、2、3或1、3、2或2、3、1等。

无论如何在Firefox中都可以使用。可能只是需要一些调整

var options = null;
var targetOption = null;
jQuery(function()
{
    options = jQuery("#foo").find("OPTION");
    options.each(function()
    {
        jQuery(this).bind("mousedown", function(event)
        {
            targetOption = jQuery(event.target);
        });
        jQuery(this).bind("mouseup", function(event)
        {
            var target = jQuery(event.target);
            if(target.is(options))
            {
                targetOption.insertAfter(target);
            }
        });
    });
});