请大神指教一下!
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>使用替换元素和内容</title> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <h3>使用replaceAll()方法替换元素内容</h3> <span class="green" title="hi">我是屌丝</span> <script type="text/javascript"> var $html = "<span class='red' title='hi'>我是土豪</span>"; $($html).replaceAll(".green"); </script> </body> </html>
为啥我把
var $html = "<span class='red' title='hi'>我是土豪</span>"
改成
var $html = "我是土豪"
这样替换不了了呢?