English 中文(简体)
ui ui ui
原标题:jquery ui selectable get id?

如果名单是动态编制的,我如何在一份可选择的清单中拿到一个项目的id?

  <ul id="selectable">
  <li id= 1 >..</li>
      .
      .
      <li...
  </ul>

I Trial var num =$ ( #selecable :s selected ).attr (“option” , id );, but have only [object Object].

正确的方式是什么?

问题回答

<>Update:

就完整性而言,如果选定一个要素,则该图文在要素上添加一个类别<代码>,即由特定部分选定<>。 因此,可以通过下列途径获得目前选定的要素的识别资料:

$( #selectable .ui-selected ).attr( id );

但是,人们知道,可以选择<>多种内容>。


The jQuery UI selectedable plugin ,在你选择一个要素时,你只得提供:

$("#selectable" ).selectable({
   selected: function(event, ui) { ... }
});

尽管如此,正如尼克已经提到的那样,国际发展研究中心不能从一位数开始。

<http://api.jquery.com/s selected-selector/“rel=“noreferer”>> 只有<代码>option要素上的工程。

这一版本不需要特定类别的名称。 使用<代码>$(由上选)。

$( "#selectable" ).selectable({
    selected: function(event, ui) {
        alert( $(ui.selected).attr( id ) );
    }
});

选定的粗金表如下:

$( #selectable ).selectable(function(){
    selected:function(){ 
        var idlist = $(this).attr( id );
        //do something with the list...of id s
    }
});
jQuery( #selectable ).selectable(function(){
    selected: function(event, ui)
    {
     jQuery(".ui-selected", this).each(function() 
     {
          var objID=jQuery(this).attr("id");
     });
    }
});
jQuery( #selectable ).selectable( function() {
    selected: function(event, ui)
    {
        alert(ui.selected.id);
    }
});

检查。

  $( ".ui-selected", this ).each(function() {
   var index = $( "#selectable li" ).attr(id);

    });
<script>
$(function () {
    $("#selectable").selectable({
        selected: function () {
            var id = $(".ui-selected", this).attr("id");
            //alert(id);
        }
    });
});





相关问题
How to start to create an application GUI using C#?

HI! I am new to C# and plan to use it for my application GUI. I am trying to make my GUI similar to SPSS:http://www.spss.com/images/08/statistics_screens/ez_rfm-big.jpg Is this easy in C#? Is there ...

Automatic height of edit box

My shoes application has three items stacked on top of each other (with a stack, of course), in order: A banner An edit box Two buttons in a flow What I want to do is have the banner stay at it s ...

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it. I mean this kind of search that is initiated by ...

UI And TcpClient Issue in vb.net

I m having some problems with a small ircbot i m writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text ...

UI Convention: Shortcut key for application exit? [closed]

Is there a convention for the shortcut keys for application exit? Some applications uses Alt+X some others use Ctrl+ X and Ctrl+Q. Applications like FF and IE doesnot assign a shortcut at all. So is ...

热门标签