Home >Web Front-end >JS Tutorial >How jquery modifies the superior element through the closest selector_jquery
The example in this article describes how jquery modifies the superior element through the closest selector. Share it with everyone for your reference. The details are as follows:
This code demonstrates that jQuery obtains the upper-level element through the closest selector, and then modifies its text() content.
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title> www.jb51.net </title> <script type='text/javascript' src='jquery-1.9.1.js'></script> <script type='text/javascript'> //<![CDATA[ $(window).load(function(){ var address = $("#jb51").closest("div"); address.text('www.jb51.net') });//]]> </script> </head> <body> <div id="website"> <div id="jb51"></div> </div> </body> </html>
Readers who are interested in more content related to jquery selector can check out the special topic of this site: "Summary of jquery selector usage"
I hope this article will be helpful to everyone’s jQuery programming.