<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
#btn
{
width:200px;height:200px;
}
</style>
<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#btn').click(function () {
alert($('img').attr('src')); //获取属性
$('img').attr('src', 'images/07.jpg'); //设置属性
$('img').attr({ src: 'images/7.jpg', title: 'Two Dog' }); //更改多个属性
alert(Math.random());
})
})
</script>
</head>
<body>
<img src="images/8.jpg" title="Baby"/>
<input id="btn" type="button" value="属性操作" />
<input id="btnUpdate" type="button" value="随机更换图片" />
</body>
</html>