1. document.getElementBy...
document.getElementsByTagName('p');
document.getElementById('p1');
document.getElementsByClassName('text');
2. 匹配指定 CSS 选择器元素,可以匹配多个,用,隔开
document.querySelector('.text'); // 方法返回类名为text的第一个子元素 。
document.querySelectorAll('.text'); // 方法返回类名为text的所有元素 。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。