<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/JQ3.3.1.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script type="text/javascript">
$(function(){//对div添加txt的样式
$(showMsg).attr("class","txt");//所有div都会有效果,其中txt是css中定义的样式
//$("#showMsg").attr("class","txt");//一次只会选中第一个div
})
</script>
</head>
<body>
<div id="showMsg"><h1>test</h1></div>
<div id="showMsg"><h1>test</h1></div>
<span>test</span>
<span>test</span>
<p>test</p>
<p>test</p>
</body>
</html>