获取元素改用jquery的写法

This commit is contained in:
many2many 2024-10-10 12:10:59 +08:00
parent 0fca78f3bc
commit 309cd1125c
2 changed files with 9 additions and 9 deletions

View File

@ -267,7 +267,7 @@ async function example() {
}).catch(error => {
// 处理任何发生的错误
console.error('There has been a problem with your fetch operation:', error);
});
});
```
代码解释:
>
@ -318,8 +318,8 @@ async function example() {
console.log('Data received:', data);
console.log('Text Status:', textStatus);
console.log('jqXHR:', jqXHR);
document.getElementById("title").innerHTML = data.title;
document.getElementById("content").innerHTML = data.body;
$("#title").html(data.title);
$("#content").html(data.body);
}).fail(function(jqXHR, textStatus, errorThrown) {
console.error('Request failed:', textStatus, errorThrown);
});
@ -332,8 +332,8 @@ async function example() {
console.log('Data received:', data);
console.log('Text Status:', textStatus);
console.log('jqXHR:', jqXHR);
document.getElementById("title2").innerHTML = data.title;
document.getElementById("content2").innerHTML = data.body;
$("#title2").html(data.title);
$("#content2").html(data.body);
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('Request failed:', textStatus, errorThrown);

View File

@ -23,8 +23,8 @@
console.log('Data received:', data);
console.log('Text Status:', textStatus);
console.log('jqXHR:', jqXHR);
document.getElementById("title").innerHTML = data.title;
document.getElementById("content").innerHTML = data.body;
$("#title").html(data.title);
$("#content").html(data.body);
}).fail(function(jqXHR, textStatus, errorThrown) {
console.error('Request failed:', textStatus, errorThrown);
});
@ -37,8 +37,8 @@
console.log('Data received:', data);
console.log('Text Status:', textStatus);
console.log('jqXHR:', jqXHR);
document.getElementById("title2").innerHTML = data.title;
document.getElementById("content2").innerHTML = data.body;
$("#title2").html(data.title);
$("#content2").html(data.body);
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('Request failed:', textStatus, errorThrown);