手机版

jQuery实现了获取h1-h6标题元素值的方法

时间:2021-09-05 来源:互联网 编辑:宝哥软件园 浏览:

阐述了用jQuery获取h1-h6标题元素值的方法。分享给大家参考,如下:

1.问题背景:

找到h1-h6并遍历它们以打印出内容

2.实现代码:

!doctype HTML HTML Head metachartset=' UTF-8 '/Title Search Title/Title Script Type=' Text/JavaScript ' src=' http : jquery-1 . 7 . 2 . min . js '/Script Script $(function(){//find h1-h6 $(' : Head ')。每个(函数(){$ (this))。click(function(event){ console . info(event . target . inner text);console . log(event . CurrentTarget . innerHTML);});});});/脚本/头体h1 hello h1/h1 H2 hello H2/H2 H3 hello H3/H3 H4 hello H4/H4 H5 hello H5/H5 h6 hello h6/h6/body/html 3、操作效果图:

更多对jQuery感兴趣的读者,请查看本站话题:《jQuery form操作技巧汇总》、《jQuery操作json数据技巧汇总》、《jQuery常用插件及用法总结》、《jQuery扩展技巧总结》、《jQuery表格(table)操作技巧汇总》、《jquery选择器用法总结》、0103010。

希望本文对大家的jQuery程序设计有所帮助。

版权声明:jQuery实现了获取h1-h6标题元素值的方法是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。