jquery获取span元素集';s值
我的div如下所示: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 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);
看起来不错,谢谢,我刚贴好,效果很好。请添加作为答案。似乎工作感谢,我只是粘贴,它的工作很好。请加上答案。