您的位置:首页 > Web前端 > JQuery

jquery随笔--选择器

2013-06-19 09:15 405 查看
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

$(document).ready(function(){

//元素选择器

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

     alert($(this).text());

});

//属性选择器

$("[name=button2]").click(function(){

    alert($("#p1").text());

});

$("[name=button3]").click(function(){

    //CSS 选择器

    $("#p1").css("color","red");

});

});

</script>

</head>

<body>

<h2>This is a heading</h2>

<p id="p1">This is a paragraph.</p>

<button type="button" id="button1">元素选择器</button><br>

<button type="button" name="button2">属性选择器</button><br>

<button type="button" name="button3">CSS 选择器</button>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jquery选择器