<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
function insertObject(obj) {
document.getElementById("demo").innerHTML = obj.arguments[0] + ' ' + obj.arguments[1];
// So I want to write "John James "
}
</script>
</head>
<body >
<button onclick="insertObject({name: "John", surname: “James”})">Try it</button>
<p id="demo"></p>
</body>
</html>
答案 0 :(得分:0)
下次请花点时间写出你的问题。
同时,希望这会让你前进
function insertObject(obj) {
document.getElementById("demo").textContent = obj.name + ' ' + obj.surname;
}
Test
<button onclick='insertObject({name: "John", surname: "James"})'>Try it</button>
<p id="demo"></p>