<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
span{
cursor: pointer;
}
div {
width: 100px;
height: 100px;
border: 1px solid black;
display: inline-block;
cursor: pointer;
}
</style>
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function() {
$('button').click(function(){
$('#box').css('background',$('input').val()).attr('class','test');//添加
alert( $('#box').attr('id'));//显示
});
})
</script>
</head>
<body>
<p>
<input type="text" name="" id="" value="" />
<button type="button">切换</button>
</p>
<div id="box"></div>
</body>
</html>
网友评论