我的DIV出現如下:jQuery的獲取設定跨度元素的值
<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>
我已經寫了下面的jQuery的東西:
var ret = AJS.$.trim(AJS.$('#customfield_11504-val .shorten span').map(function() {
return AJS.$(this).html();
}).get().join(", "));
console.log("ret is:" + ret);
它打印出我如下:
[object HTMLSpanElement],[object HTMLSpanElement],[object H TMLSpanElement]
這是什麼錯在這裏..我試過,文字,但仍然只是給我這隻。
似乎工作[小提琴](http://jsfiddle.net/LqW89/) –
謝謝,我只是粘貼,它工作正常。請添加爲答案。 – dsi
很高興幫助! –