<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
var $first_p = $("p:eq(0)");
$first_p.attr({"id":"first_p","value": "hello"});
alert($("#first_p").val()); //"hello"
});
});
</script>
<style type="text/css">
.main
{
font-size:120%;
color:red;
}
</style>
</head>
<body>
<h1 id="h1">This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button id="default">default</button>
<button id="large">large</button>
<button id="small">small</button>
</body>
</html>
jquery学习之为多个属性同时赋值
最新推荐文章于 2021-01-27 02:47:39 发布