`
Jellen129
  • 浏览: 62603 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

1. JQuery初体验--helloWorld

阅读更多

 

 

初学 JQuery,经典的hello world!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>初学JQuery</title>

<script language="javascript" src="jquery-1.8.2.js" type="text/javascript"></script>
</head>

<body>
<div>一、引入"jquery-1.8.2.js"文件,进入JQuery的初体验吧!如下:<br/>
<input id="helloWorld1" type="button" value="点击我呀,隐藏"/>
<input id="helloWorld2" type="button" value="点击我呀,显示"/>
<input id="helloWorld3" type="button" value="点击我呀,显示或隐藏"/>
<p style="background-color:#CCC">点击按钮显示或隐藏此。 hello world!</p>
</div>

</body>


<script language="javascript">
$(document).ready(function(){//它的缩写方法:$(function(){ //do something   });
$("#helloWorld1").click(function(){
$("p").hide();
});

$("#helloWorld2").click(function(){
$("p").show();
});

$("#helloWorld3").click(function(){
$("p").toggle();
});

});

</script>
</html>
分享到:
评论

相关推荐

    jquery-1.3.2.js

    例如,`$("div").append("&lt;p&gt;Hello World&lt;/p&gt;")`会在每个`&lt;div&gt;`元素内部追加一个`&lt;p&gt;`标签。 ### 3. 事件处理 jQuery的事件处理方式非常直观,`click()`, `mouseover()`, `mouseout()`等方法让事件绑定变得轻松。...

    jQuery经典

    alert("Hello World!"); }); ``` #### 二、jQuery对象与DOM对象 **1. jQuery对象** - **定义** jQuery对象是指通过jQuery包装DOM对象后产生的对象。它是jQuery特有的对象类型。 - **使用** 如果一个...

    JQuery基础入门

    例如:`$("&lt;div&gt;&lt;p&gt;Hello World&lt;/p&gt;&lt;/div&gt;").appendTo("body")`,这将在页面的`&lt;body&gt;`标签内创建并添加一个新的`&lt;div&gt;`元素及其内容。 - `$(elements)`:将一个或多个DOM元素转换成JQuery对象。例如:`$(document....

    blog:我的hexo博客

    1. **内容创建**:Hexo支持Markdown、Textile等多种文本格式,用户只需在指定的 `_posts` 目录下创建文章,按照约定的文件命名规则(如:`2022-01-01-hello-world.md`),并编写文章内容。 2. **配置**:Hexo的配置...

    明信片API

    message: 'Hello from the API world!' }) }) .then(response =&gt; response.json()) .then(data =&gt; console.log(data)) .catch(error =&gt; console.error(error)); ``` 4. **错误处理**:在调用API时,可能会...

Global site tag (gtag.js) - Google Analytics