84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
js如何获取a标签<strong>文本</strong>中的文本
<strong>
</strong>
<a class="slogo-shopname" data-spm-anchor-id="a1z10.1-b-s.1997427721.d4918089"><strong>ochirly</strong></a>
业精于勤,荒于嬉;行成于思,毁于随。
var text=document.querySelector(".slogo-shopname strong").innerHTML;
之所以用innerHTML而不用innerText是因为innerHTML已纳入HTML5规范,而innerText没有。innerText可能有兼容性问题。
jquery:
$(".slogo-shopname strong:contains('ochirly')")
document.getElementsByClassName('class')[0].children[0].innerText
javascript: document.querySelector(".slogo-shopname strong").innerText; jquery: $(".slogo-shopname strong").text();
查询纯文本形式的元素内容,标准的方法是用Node的textContent属性来实现,以下代码供参考,你试试
var strong = document.getElementsByTagName('strong')[0]; var text = strong.textContent; console.log(text);
var value_ = $("a").text();
alert(value_);
'<a class="slogo-shopname" data-spm-anchor-id="a1z10.1-b-s.1997427721.d4918089"><strong>ochirly</strong></a>'.match(/<strong.*?>(.*?)<\/strong>/)[1]
JQ:
var Sval = $('.cccc strong').text();
$(".slogo-shopname strong").text();
之所以用innerHTML而不用innerText是因为innerHTML已纳入HTML5规范,而innerText没有。innerText可能有兼容性问题。
jquery:
document.getElementsByClassName('class')[0].children[0].innerText
查询纯文本形式的元素内容,标准的方法是用Node的textContent属性来实现,以下代码供参考,你试试
var value_ = $("a").text();
JQ:
$(".slogo-shopname strong").text();