jquery随笔--获取控件的值
来源:互联网 发布:英语杂志软件 编辑:程序博客网 时间:2024/06/05 16:59
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
//通过text()获取P标签的值
$("#but1").click(function(){
alert($("p").text());
});
//通过val()获取P标签的值
$("#but2").click(function(){
alert($("p").val());
});
//通过html()获取P标签的值
$("#but3").click(function(){
alert($("p").html());
});
//通过text()获取输入框的值
$("#but4").click(function(){
alert($("input").text());
});
//通过val()获取输入框的值
$("#but5").click(function(){
alert($("input").val());
});
//通过html()获取输入框的值
$("#but6").click(function(){
alert($("input").html());
});
$("#but7").click(function(){
alert($("a").attr("href"));
});
});
</script>
</head>
<body>
<form action="">
<p>这是段落中的<b>粗体</b>文本。</p>
<button id="but1">通过text()获取值</button>
<button id="but2">通过val()获取值</button>
<button id="but3">通过html()获取值</button><br><br>
<input type="text" value="这是输入框中的<b>粗体</b>文本。"><br><br>
<button id="but4">通过text()获取值</button>
<button id="but5">通过val()获取值</button>
<button id="but6">通过html()获取值</button><br>
<p><a href="http://www.baidu.com" id="w3s">baidu.com</a></p>
<button id="but7">显示 href 值</button>
<p></p>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
//通过text()获取P标签的值
$("#but1").click(function(){
alert($("p").text());
});
//通过val()获取P标签的值
$("#but2").click(function(){
alert($("p").val());
});
//通过html()获取P标签的值
$("#but3").click(function(){
alert($("p").html());
});
//通过text()获取输入框的值
$("#but4").click(function(){
alert($("input").text());
});
//通过val()获取输入框的值
$("#but5").click(function(){
alert($("input").val());
});
//通过html()获取输入框的值
$("#but6").click(function(){
alert($("input").html());
});
$("#but7").click(function(){
alert($("a").attr("href"));
});
});
</script>
</head>
<body>
<form action="">
<p>这是段落中的<b>粗体</b>文本。</p>
<button id="but1">通过text()获取值</button>
<button id="but2">通过val()获取值</button>
<button id="but3">通过html()获取值</button><br><br>
<input type="text" value="这是输入框中的<b>粗体</b>文本。"><br><br>
<button id="but4">通过text()获取值</button>
<button id="but5">通过val()获取值</button>
<button id="but6">通过html()获取值</button><br>
<p><a href="http://www.baidu.com" id="w3s">baidu.com</a></p>
<button id="but7">显示 href 值</button>
<p></p>
</form>
</body>
</html>
- jquery随笔--获取控件的值
- jquery随笔--设置控件的值
- jquery随笔--控件追加值
- jquery随笔--控件的隐藏显示
- JQuery UI 控件随笔
- jQuery获取 控件值
- JQUERY获取各种HTML控件的值
- jquery获取服务器控件的值
- Jquery 设置或获取控件的值
- jquery获取控件值的方法
- jquery获取控件值的方法
- Jquery 获取不同控件的值
- jquery获取radio控件的值
- JQuery获取控件属性值的方法
- Jquery 设置或获取控件的值
- jquery获取easyui日期控件的值
- Jquery获取Select选中控件的值
- jquery获取控件值(总结)
- SQL触发器,初试牛刀(一)
- 计算机科学中最重要的32个算法
- JDBC 学习笔记(二)—— 大数据+存储过程+批处理+事务
- iOS 获取手机的型号,系统版本,软件名称,软件版本
- 联机事务处理 OLTP
- jquery随笔--获取控件的值
- 队列的基本操作(采用链式存储结构)
- 【Cocos2d-x游戏引擎开发笔记(25)】XML解析
- 树形结构的数据库表Schema设计
- [Android开发常见问题-1] 中文注释和中文字符串乱码
- 提高rails new时bundle install运行速度
- 制作独立运行的android模拟器
- 2013-6-19-1-js-正则表达式对象
- cocos2d-x初探学习笔记(24)--音乐音效