Home > Web Front-end > JS Tutorial > How jquery modifies the superior element through the closest selector_jquery

How jquery modifies the superior element through the closest selector_jquery

WBOY
Release: 2016-05-16 16:09:10
Original
1399 people have browsed it

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>
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template