简体   繁体   English

如何在鼠标单击时显示包含jQuery UI Selectable的div

[英]How to show a div that contain a The jQuery UI Selectable on mouse click

I want to find a mouse position that was clicked on and a div that contains a show up,this div should contain a Selectable I know how to find a mouse position and show a div,but I got an error when I tried to fill a div with selectable. 我想找到一个被单击的鼠标位置以及一个包含显示内容的div,该div应该包含一个Selectable。我知道如何找到一个鼠标位置并显示一个div,但是当我尝试填充一个div时出现错误带有可选的div。 Can you show me a sample how to write this script? 您能告诉我一个如何编写此脚本的示例吗?

$(function() {
    $( "#selectNewsType" ).click(function(e) {
                  $("<ol/>",{
            "id" : "selectable",
            "style":"border:1px solid;width:200px;position:absolute;left:" + (e.pageX - 200) + "px;top:" + e.pageY + "px;"

        }).appendTo("body")
        .append( $(function(){
            $.each(a.rows,function(k,v){
                $("<li>",{      
                    id:k,
                    text:a.rows[k].cell[0],
                    className:"ui-widget-content"

                }).appendTo("#selectable");
            })           
        }))
        .show();

    });
});

I made a simple example using jQuery selectable example - click here . 我使用jQuery可选示例制作了一个简单示例- 单击此处 First the div containing selectable is hidden, upon clicking anyway it is showed. 首先,包含selectable的div被隐藏,无论如何单击都会显示它。 I did not bothered with getting mouse position but otherwise it works. 我没有为获取鼠标位置而烦恼,但其他方法都可以。

Is this what you wanted? 这就是你想要的吗?

K ķ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM