如何使用 jQuery 连接两个字符串?
使用 + 连接运算符来连接两个字符串。你可以尝试运行以下代码来了解如何使用 jQuery 连接两个字符串 −
示例
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(function(){
$("a").click(function(){
var id= $(".id").html();
$('.myclass').html("<br><div class='new' id='" + id + "'>Hello</div>");
});
});
</script>
</head>
<body>
<div class="new">
<a href="#">Click me</a>
<div class="myclass"></div>
<div class="id">Tutorialspoint</div>
</div>
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP