代码之家  ›  专栏  ›  技术社区  ›  Brian Hicks

在可排序的jQuery中选择文本框的内容

  •  1
  • Brian Hicks  · 技术社区  · 17 年前

    我试图获取jQuery中可排序项内文本区域的内容。..我似乎弄不明白!以下是我现在所拥有的:

    jQuery(document).ready(function() { 
        jQuery("#list").sortable({
            axis : 'y' ,
            revert : 'true' ,
        opacity : 0.5 ,
        stop : function (e, ui) {
            jQuery("input#output"); 
        }
        });                             
    });
    

    3 回复  |  直到 17 年前
        1
  •  1
  •   Ben Koehler    17 年前

    只是想一些你可以尝试的东西(不看你的html标记)

    jQuery(this).children('textarea#output').val();
    jQuery(this).children('#output').val(); // this line may be all you need as well
    
        2
  •  2
  •   Jon Erickson    17 年前

    用户界面 在停止功能中,将刚刚移动的可排序对象保持在 ui.item .

    ui.item.children("textarea.output").val();  //whatever one you may need.
    ui.item.children(".output").val();
    ui.item.children("textarea").val();
    

    我还将“#output”更改为“.output”,因为标准做法是不要有多个具有相同id的元素(假设在每个可排序项目中都有一个具有输出id的文本框)。如果它们是相似的元素,请将它们设置为同一类。

        3
  •  1
  •   ichiban    17 年前

    编辑:

    jQuery(this).children("textarea#output").val(); //for a textarea
    jQuery(this).children("input#output").val(); //for a textbox
    
    推荐文章