- 通过id查找html元素
<!DOCTYPE html> <html> <body> <div class="hi"> <p class="hi" name="hi" id="hi">hello</p><br> </div> </body>
<script> var x=document.getElementById("hi"); console.log(x); document.write("通过javascript获取内容为:"+x.innerHTML); </script>
- 通过类名查找html元素
<script> var x=document.getElementsByClassName("hi"); console.log(x); document.write("通过javascript获取内容为:"+x[1].innerHTML); </script>
- 通过标签名查找html属性
<script>
var x=document.getElementsByTagName("p");
console.log(x);
document.write("通过javascript获取内容为:"+x[0].innerHTML);
</script>
swiper插件
swiper是一款开源的解决前端开发中触摸滑动案例的插件
能实现触屏焦点图、触屏Tab切换、触屏轮播图切换等常用效果。
使用swiper首先要下载swiper
下载完成后在官网在线演示中找到你所需要的