[英]Get the span element next to the current span with the same class
I have 我有
<span class="mention-persons">
<span class="link-text" id="parent4a275ca0-1bbd-11e4-8b7c-a02bb830bf59">
<span class="and_text"></span> Elephant Melephant<span onclick="deletemention(this);" id="4a275ca0-1bbd-11e4-8b7c-a02bb830bf59" class="delete-tag">×</span>
</span>
<span class="link-text" id="parent5991dff0-1bcf-11e4-908f-a02bb830bf59">
<span class="and_text">and</span> Dogs Cats<span onclick="deletemention(this);" id="5991dff0-1bcf-11e4-908f-a02bb830bf59" class="delete-tag">×</span>
</span>
</span>
Is it possible if i am at at the first link-text
or at first and_text
or at first delete-tag
element i can get the next and-text
element using jquery and set it text to empty? 如果我位于第一个
link-text
,第一个and_text
或第一个delete-tag
元素,是否可以使用jquery获取下一个and-text
元素并将其文本设置为空?
If you're at the first link-text
: 如果您在第一个
link-text
:
$(this).next('.link-text').children('.and_text').empty();
If you are at the first .link-text
or .delete-tag
use: 如果您是第一个
.delete-tag
.link-text
或.delete-tag
使用:
$(this).closest('.link-text').next('.link-text').children('.and_text').empty();
UPDATE UPDATE
Irrespective of where you are on the first .link-text
, you can use the following: 无论您在第一个
.link-text
上的位置如何,都可以使用以下命令:
var that = $(this).is('.link-text') ? $('.link-text') : $(this).closest('.link-text');
that.next('.link-text').children('.and_text').empty();
您可以尝试如下操作:
$(this).parents(".link-test").next(".link-text").children(".and_text").text('');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.