Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
<div class='test'> <strong> 1</strong> </div>
我试过$(.test).find('strong')了,我认为这不是正确的方法,因为我无法找到元素
$(.test).find('strong')
我正在寻找强大的 html (仅值 1,而不是下面的某些文本和其他部分。
正确的方法是什么?
很简单,但我的错我没有做对!
您尝试了正确的方法(复制粘贴错误除外 - 丢失'')
''
$('.test').find('strong').html()
演示:小提琴
尝试以下操作:
console.log($('.test strong')[0].outerHTML);
演示:JSFIDDLE
或者
console.log($('.test strong')[0].innerHTML);
如果您的 html 中只有一个strong。你也可以试试这个 -
strong
$('strong').html()
而是使用
尝试这个