当前位置:网站首页>JS-DOM element object
JS-DOM element object
2022-08-11 02:56:00 【(- ^ _ ^)】
Get DOM properties for text and HTML content
innerHTML--------text or HTML tags in the node--------embedded in HTML (requires only text to prohibit tags)
innerText - the text inside the node has no HTML tags - only supports IE browsers
textContent - the text inside the node has no HTML tags - except for IE browsers
value - text in form control - input
Use DOM to adjust styles (color backgroundColor border, etc. and CSS have case differences)
Use JS code to set font boldness and style:
Set the font with JS code (use a function, the key point for setting different fonts is this)
JS code to set font size
Webpage Lorem ipsum dolor sit.
Lorem ipsum dolor sit.
Lorem ipsum dolor sit.
Lorem ipsum dolor sit.
Lorem ipsum dolor sit.
Lorem ipsum dolor sit.
Font: Serif Fantasy Monosapce
Style: Bold bold Ttalic oblique
function bold(){var a=document.getElementById('1');//Add positionif(this.checked){a.style.fontWeight="bold";}else{a.style.fontWeight="normal";}}function italic(){var a=document.getElementById('1');//Add positionif(this.checked){a.style.fontStyle="italic";}else{a.style.fontStyle="normal";}}function fontset(){var a=document.getElementById('1');//Add positiona.style.fontFamily=this.id; //current window//The font size is increased by 2pt, the original font size and 12 are selected to achieve the setting of 12 andvar oldSize =parseInt(a.style.fontSize) ||12;a.style.fontSize=(oldSize+2)+"pt";//Convert into characters, each time you select it, the font will expand}window.onload=function(){document.getElementById('bold').onclick=bold;//The above is connected into a sentencedocument.getElementById('italic').onclick=italic;document.getElementById('serif').onclick=fontset;document.getElementById('fantasy').onclick=fontset;document.getElementById('monosapce').onclick=fontset;}
边栏推荐
猜你喜欢
随机推荐
ES进阶 数组功能语法新特性详解
Detailed explanation of new features of ES advanced function syntax
[idea error] Invalid target distribution: 17 solution reference
MySQL权限控制、分区表、快速复制表
AI+医疗:使用神经网络进行医学影像识别分析
Multi-threaded ThreadPoolExecutor
Oops novice template Framework project guide
夫妻一方婚内向异性大额转款,怎么判
TRCX: doping process analysis
调试技巧总结
四大组件---ContentResolver
The ifconfig compared with IP command
全局大喇叭--广播机制
Some work experience after joining the digital ic design
Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
A surviving spouse of the opposite sex within large turn paragraph, what for
21天学习挑战赛第一周总结
shell脚本入门
(CVPR - 2017) in depth and potential body learning context awareness feature for pedestrian recognition
LitePal操作数据库