最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jQuery实现获取h1-h6标题元素值的方法
时间:2017-05-30 编辑:简简单单 来源:一聚教程网
1、问题背景:
查找到h1-h6,并遍历它们,打印出内容
2、实现代码:
$(function(){
//查找h1-h6
$(":header").each(function(){
$(this).click(function(event){
console.info(event.target.innerText);
console.log(event.currentTarget.innerHTML);
});
});
});
Hello H1
Hello H2
Hello H3
Hello H4
Hello H5
Hello H6
3、运行效果图:
相关文章
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31
- HTML中空格表示的意义 10-31
- html area标签解读 10-31
- html使用表单标签实现注册页面代码展示 10-31
- 使用HTML截图并保存为本地图片的代码展示 10-31