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.
如何从这个 a href 标签中提取(使用 jQuery)数字?
<a href="#slide1"></a> <a href="#slide2"></a> <a href="#slide3"></a>
非常感谢您的帮助。
像这样的东西应该工作:
$('a').each(function() { alert($(this).prop('href').replace(/[^\d]+/, '')); });
$('a').each(function(){ alert($(this).prop("href").replace("#slide","")); });
试试这个
现场演示