Write your first jQuery program
Write a program
Create an html page, introduce the jQuery class library and write the following code:
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8"/>
<title>Hello World jQuery!</title>
<script src="http://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<body>
<div id="divMsg">Hello jQuery!</div>
<input id="btnShow" type="button" value="show" />
<input id="btnHide" type="button" value="hidden" /><br/>
<input id="btnChange" type="button" value="change content is Hello World, too!"/>
<script>
$("#btnShow").bind("click", function(event) {
$("#divMsg").show();
});
$("#btnHide").bind("click", function(event) {
$("#divMsg").hide();
});
$("#btnChange").bind("click", function(event) {
$("#divMsg").html("Hello World, too!");
});
</script>
</body>
</html>The effect is as follows:
There are three buttons on the page, which respectively control the display, hiding and modifying the content of Hello World.
This example uses:
(1) jQuery ID selector: $("#btnShow") (2) Event binding function: bind() (3) Show and hide Functions: show() and hide() (4) Function to modify the html inside the element: html()
new file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>第一个简单的jQuery程序</title>
<style type="text/css">
div{
padding:8px 0px;
font-size:12px;
text-align:center;
border:solid 1px #888;
}
</style>
<script src="http://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("div").html("在php中文网学习,才是最好的学习途径。");
});
</script>
</head>
<body>
<div></div>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















