当前位置: 首页 > news >正文

无涯教程-jQuery - html( )方法函数

html(val)方法获取第一个匹配元素的html内容(innerHTML)。此属性在XML文档上不可用。

html( ) - 语法

selector.html( )

html( ) - 示例

以下是一个简单的示例,简单说明了此方法的用法-

<html><head><title>The jQuery Example</title><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><script type="text/javascript" language="javascript">$(document).ready(function() {$("div").click(function () {var content=$(this).html();$("#result").html(content);});});</script><style>.div{ margin:10px;padding:12px; border:2px solid #666; width:60px;}</style>	</head><body><p>Click on any square below to see the result:</p><p id="result"> THIS IS TEST </p><div class="div" style="background-color:blue;"><h1>This is square one </h1></div><div class="div" style="background-color:green;"><h1>This is square two </h1></div><div class="div" style="background-color:red;"><h1>This is square three </h1></div></body>
</html>

这将产生以下输出-

参考链接

https://www.learnfk.com/jquery/dom-html.html

http://www.lryc.cn/news/101713.html

相关文章:

  • Linux vsftp三种模式的简单配置部署
  • 6.1.tensorRT高级(1)-概述
  • 【Python】将M4A\AAC录音文件转换为MP3文件
  • 个性新颖纯css手风琴效果选项卡
  • js的sendBeacon方法介绍
  • 【Tomcat---1】IDEA控制台tomcat日志输出乱码解决
  • Redis学习路线(2)—— Redis的数据结构
  • 【Redis深度专题】「核心技术提升」探究Redis服务启动的过程机制的技术原理和流程分析的指南(持久化功能分析)
  • IT管理者年过50后何去何从
  • C++字符串题基础(进阶请看下一个文章)
  • webpack如何实现热更新?
  • REST API的基础:HTTP
  • 基于Docker-compose创建LNMP环境并运行Wordpress网站平台
  • 【雕爷学编程】MicroPython动手做(02)——尝试搭建K210开发板的IDE环境3
  • Java语言跨平台执行的核心JVM
  • 家政服务小程序制作攻略揭秘
  • 2023-07-29力扣每日一题
  • Dual pyramid GAN for semantic image synthesis
  • 【Linux】更换jdk版本
  • web-暴力破解密码
  • 基础实验篇 | CopterSim中回传提示消息实验
  • vue基础-动态style
  • vue3使用响应式数据 + v-model导致响应式失效el-form表单无法输入的问题
  • 线段树详解 原理解释 + 构建步骤 + 代码(带模板)
  • Java中Timer的使用
  • 关于EJB,这两文把热闹和门道都说清楚了
  • MixFormerV2: Efficient Fully Transformer Tracking
  • K8S中网络如何通信
  • LangChain Agents深入剖析及源码解密上(三)
  • 分布式限流方案及实现