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.
如何在页面上搜索字符串,然后将文本包装在一个元素中,比如“”?
因此,例如,我搜索名称“Alex”,每当我找到该名称时,它都会将其替换为“Alex”?
那可能吗?
尝试这样的事情:
$('*:contains("Alex")').each(function(){ $(this).html($(this).text().replace('Alex','/"Alex/"')); });