手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >使用jQuery获得内容以及内容的属性
使用jQuery获得内容以及内容的属性
摘要:复制代码代码如下:body{font-family:"微软雅黑";width:980px;margin:0auto;text-align:c...

复制代码 代码如下:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<script src="js/jquery.js"></script>

</head>

<style>

body{font-family: "微软雅黑";width: 980px; margin: 0 auto; text-align: center;}

.box{

width: 300px;

height: 300px;

background: green;

border: 1px solid #e6e6e6;

line-height: 200px;

position: absolute;

}

button{

border: none;

background: green;

width: 125px;

height: 50px;

line-height: 50px;

color: #fff;

font-size: 16px;

margin-top: 50px;

font-family: "微软雅黑";

}

</style>

<body>

<button id="btn1">显示text</button>

<button id="btn2">显示html</button>

<button id="btn3">显示输入内容</button>

<p id="text">这是要显示<b>粗体</b>的节奏</p>

<br />

<input id="input" value="买房子">

<script>

$(document).ready(function(){

$("#btn1").click(function(){

alert("Text: " + $("#text").text());

});

$("#btn2").click(function(){

alert("HTML: " + $("#text").html());

});

$("#btn3").click(function(){

alert("Value: " +$("#input").val());

});

});

</script>

</body>

</html>

Tips:

1、点击事件节点的选择 #botton

2、alert 的代码规则 ("Value: " + $("#id").html)

今天的分享就先到这里了,后续我们还将持续更新一些新的jQuery实例。

【使用jQuery获得内容以及内容的属性】相关文章:

jQuery封装的tab选项卡插件分享

jQuery常用知识点总结以及平时封装常用函数

jQuery实现延迟跳转的方法

列表内容的选择

jQuery实现表格行上移下移和置顶的方法

JQuery自动触发事件的方法

用于table内容排序

jQuery计算文本框字数及限制文本框字数的方法

jQuery获取上传文件的名称的正则表达式

jQuery获取字符串中出现最多的数

精品推荐
分类导航