<style>
select{
width:300px
border:#CCC solid 1px
border-radius:2px
font-size:18px
color:#CCC
line-height:35px
height:35px
}
</style>
<body>
<select>
<option>select Box
</option>
</select>
</body>
cloneNode 是用来复制节点的,想复制css class name,可以用下面两种方法中的任意一种:<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="coolwp.com">
</head>
<body onload="cloneCssClass()">
<div class="red"></div>
<div></div>
<script>
function cloneCssClass(){
document.getElementsByTagName("div")[1].className = document.getElementsByTagName("div")[0].className
console.log( document.getElementsByTagName("div")[1])
}
/*
或者,去掉body 上的 onload="cloneCssClass()" 只用下面的
document.getElementsByTagName("div")[1].className = document.getElementsByTagName("div")[0].className
*/
</script>
</body>
</html>