您好我正在尝试从链接上方的 span 元素中获取文本。
$(this).closest("span").text()
完整代码:
JS
$boxes.find('.portlet-header .portlet-maximize').click(function() {
// returns the rel of the link fine
var widHtml = $(this).attr('rel');
// get text from span above link (not working)
var widTitle = $(this).closest("span").text()
});
HTML
<div class="portlet-header">
<span class="widTitle gmIcon">text I want to get</span>
<a rel="widgets/dashboard/max/goal-mouth" class="portlet-maximize"></a>
</div>