如何设置或返回元素应使用JavaScript划分的列数?
要将div分为三列,请使用columnCount属性。设置列数并除以div。
示例
您可以尝试运行以下代码以返回使用JavaScript将元素划分为的列数-
<!DOCTYPE html>
<html>
<body>
<p>Click below to create 4 columns</p>
<button onclick="display()">Columns</button>
<div id="myID">
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
This is demo text. This is demo text. This is demo text. This is demo text.
</div>
<script>
function display() {
document.getElementById("myID").style.columnCount = "4";
}
</script>
</body>
</html>热门推荐
10 关于早晨的祝福语简短
11 中秋祝福语简短版大全
12 生日祝福语简短独特格式
13 新老师祝福语 简短独特
14 简短祝福语中考女孩的话
15 拜新年的祝福语简短
16 圣诞简短祝福语给父母
17 祝产妇的祝福语简短
18 对司机的祝福语简短