Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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
jquery获取span元素集';s值_Jquery - Fatal编程技术网

jquery获取span元素集';s值

jquery获取span元素集';s值,jquery,Jquery,我的div如下所示: <div id="customfield_11504-val" class="value type-multiselect editable-field inactive" data-fieldtype="multiselect" data- fieldtypecompletekey="com.atlassian.jira.plugin.system.customfieldtypes:multiselect" title="Click to edi

我的div如下所示:

 <div id="customfield_11504-val" class="value type-multiselect editable-field inactive"     data-fieldtype="multiselect" data-   fieldtypecompletekey="com.atlassian.jira.plugin.system.customfieldtypes:multiselect"    title="Click to edit">
 <div class="shorten" id="customfield_11504-field" style="height: auto;">
   <span>option 3</span>
                         ,
       <span>option 2</span>
                            , 
        <span>option 1</span>
  </div>
 <span class="overlay-icon icon icon-edit-sml"/>
</div>
它将我打印如下:

 <div id="customfield_11504-val" class="value type-multiselect editable-field inactive"     data-fieldtype="multiselect" data-   fieldtypecompletekey="com.atlassian.jira.plugin.system.customfieldtypes:multiselect"    title="Click to edit">
 <div class="shorten" id="customfield_11504-field" style="height: auto;">
   <span>option 3</span>
                         ,
       <span>option 2</span>
                            , 
        <span>option 1</span>
  </div>
 <span class="overlay-icon icon icon-edit-sml"/>
</div>
[object HtmlPanelElement]、[object HtmlPanelElement]、[object HtmlPanelElement]

这里怎么了。。我试过了,但还是只给我这个。

试试这个

$(this).text() ;
试试这个

$(this).text() ;
将为你的事业服务

将为您的事业服务。

您可以这样做:

var ret = $.trim($('#customfield_11504-val .shorten span').map(function () {
    return $(this).html();
}).get().join(", "));

console.log("ret is:" + ret);
您可以这样做:

var ret = $.trim($('#customfield_11504-val .shorten span').map(function () {
    return $(this).html();
}).get().join(", "));

console.log("ret is:" + ret);

看起来不错,谢谢,我刚贴好,效果很好。请添加作为答案。似乎工作感谢,我只是粘贴,它的工作很好。请加上答案。