jquery is a way to modify the parent element through the closest selector
- 2020-05-16 06:24:36
- OfStack
The example in this article shows how jquery modifies the parent element through the closest selector. Share with you for your reference. The details are as follows:
This code demonstrates that jQuery gets elements from the upper level 1 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.ofstack.com </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.ofstack.com')
});//]]>
</script>
</head>
<body>
<div id="website">
<div id="jb51"></div>
</div>
</body>
</html>
For more information about jquery selectors, please visit the topic "summary of jquery selectors".
I hope this article is helpful for you to design jQuery program.