<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<style>
.P_border{
border: 1px solid red;
}
.p-border{
border:0px ;
}
</style>
<script type="text/javascript">
function addBorder(){
var pList=document.getElementsByTagName("p");
for(var i=0;i<pList.length;i++){
pList[i].className="P_border";//为制定元素添加边框
}
}
function clearBorder(){
var pList=document.getElementsByTagName("p");
for(var i=0;i<pList.length;++i){
pList[i].className="p-border";
}
}
</script>
<body>
<p>世上无难事。只怕有心人</p><br />
<p>龙与少年游</p><br />
<p>子在川上曰,逝者如斯夫不舍昼夜</p>
<input type="button"value="加上边框" onclick="addBorder()" />
<input type="button"value="清除边框" onclick="clearBorder()"/>
</body>
</html>