<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
$('br').replaceWith('<hr color="yellow"/>');
//$('<hr color="yellow"/>').replaceAll('br');
});
$('#btn2').click(function () {
$('br').replaceAll('hr');
})
})
</script>
</head>
<body>
<input type="button" name="name" value="替换1" id="btn" /><br />
<input type="button" name="name" value="替换2" id="btn2" /><br />
静夜思<br />
床前明月光,<br />
疑是地上霜,<br />
举头望明月,<br />
低头思故乡。<br />
</body>
</html>
jquery 替换元素
推荐阅读
- UIStackView before iOS9.0
- 删除安装的 cocoapods 的缓存方法
- [Project Name] was compiled with optimization - stepping may behave oddly; variables may not be available.
- GIT 从入门到放弃大整理
- 如何创建 Code Snippet
- AFN请求后台返回数据为NSInlineData类型的处理
- UISearchController Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior
- vue入门以及Webstorm 添加新建.vue文件功能并支持高亮vue语法和es6语法
- get() eq()区别
- js中return;、return true、return false 区别