Javascript 如何使用jQuery选择没有类或id的文本?
我想从下面的html中选择文本,我只想选择此文本 Adobe Illustrator、Adobe PhotoshopJavascript 如何使用jQuery选择没有类或id的文本?,javascript,jquery,Javascript,Jquery,我想从下面的html中选择文本,我只想选择此文本 Adobe Illustrator、Adobe Photoshop <div class="col-xs-12"> <h4 class="dl-title">Professional Skills</h4> <div class="divider"></div> Adobe Illustrator, Adobe Photoshop 我使用等式(15),因为我要从中获取数据的网站中有
<div class="col-xs-12">
<h4 class="dl-title">Professional Skills</h4>
<div class="divider"></div>
Adobe Illustrator, Adobe Photoshop
我使用等式(15),因为我要从中获取数据的网站中有很多.col-xs-12
请帮帮我!提前感谢请使用此:
$('.col-xs-12').children().remove().end().text().trim()
当您需要添加任何类或.eq(15),然后添加时,请使用以下命令:
$('.col-xs-12').children().remove().end().text().trim()
当您需要添加任何类或.eq(15)时,请添加尝试使用
$.parseHTML()
,.html()
,Array.prototype.pop()
,.textContent
var text = $.parseHTML($(".col-xs-12").eq(15).html()).pop().textContent;
var text=$.parseHTML($(.col-xs-12”).html()).pop().textContent;
console.log(文本)
专业技能
Adobe Illustrator、Adobe Photoshop
尝试使用$.parseHTML()
,.html()
,数组.prototype.pop()
,.textContent
var text = $.parseHTML($(".col-xs-12").eq(15).html()).pop().textContent;
var text=$.parseHTML($(.col-xs-12”).html()).pop().textContent;
console.log(文本)
专业技能
Adobe Illustrator、Adobe Photoshop
试试这个
$(".col-xs-12")
.clone() //clone the element
.children() //select all the children
.remove() //remove all the children
.end() //again go back to selected element
.text();
试试这个
$(".col-xs-12")
.clone() //clone the element
.children() //select all the children
.remove() //remove all the children
.end() //again go back to selected element
.text();
$('.col-xs-12:eq(15).divider')[0].nextSibling.textContent
@ArunPJohny,这应该是答案。我不知道你为什么不把它放进去..$('.col-xs-12:eq(15).divider')[0]。nextSibling.textContent
@ArunPJohny,这应该是答案。我不知道你为什么不把它放在……非常感谢大家:)非常感谢大家:)