2-2 编程练习
来源:2-2 编程练习
maggiecl
2019-09-17 14:53:17
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>模版字符串</title>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
<script type="text/javascript">
let person ={
name:"xiaoming",
age:18
}
$(".div1").append(
"He is <b>" + person.name + "</b>" + "and we wish to know his" + person.age + ".That is all<br>"
);
// 补充代码
$(".div2").append(
`He is <b>${person.name}</b> and we wish to know his ${person.age}. That is all<br>`
);
</script>
</body>
</html>
这样写可以吗?
1回答
你好同学,效果实现的正确,很棒哦。祝学习愉快,望采纳。
相似问题