这段代码演示了jQuery通过closest选择器上一级的元素,然后修改其text()内容
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title> www.75271.com </title> <script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script> <script type='text/javascript'>//<![CDATA[ $(window).load(function(){ var address = $("#sharejs").closest("div"); address.text('www.75271.com') });//]]> </script> </head> <body> <div id="website"> <div id="sharejs"></div> </div> </body> </html>