当前位置:网站首页>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;}边栏推荐
猜你喜欢

DOM树的遍历-----修改样式,选择元素,创建和删除节点

The practice of alibaba data synchronization component canal

BUU brushing record

JS-DOM元素对象

google搜索技巧——程序员推荐

【idea 报错】 无效的目标发行版:17 的解决参考

flink The object probably contains or references non serializable fields.

添加用户报错useradd: cannot open /etc/passwd

关于地图GIS开发事项的一次实践整理(上)

Add user error useradd: cannot open /etc/passwd
随机推荐
重庆纸质发票再见!开住宿费电子发票即将全面取代酒店餐饮加油站发票
js中的this问题
2022制冷与空调设备运行操作考试试题模拟考试平台操作
Future Trends in Vulnerability Management Programs
解决vim与外界的复制粘贴(不用安装插件)
基于FPGA状态机的自动售货机功能实现
ifconfig与ip命令的比较
CSAPP Data Lab
掌握这几招,轻松K.O面试官,Offer拿到吐
The practice of alibaba data synchronization component canal
Multi-threaded ThreadPoolExecutor
Mysql_Note6
postgresql ilike create function
Some work experience after joining the digital ic design
IDE编译报错:Dangling metacharacter
JVM类加载机制
深度学习-第二次
ESP32的环境配置(arduino arduino2.0 VScode platform哪个好用?)
[BX]和loop
数据存储全方案----详解持久化技术