jquery 時代的眼淚

專案遇到只要來紀念一下時代的眼淚,筆記一下,之後比較好 coding

1
2
3
```jsx // element [ 'class' | '#class' | p | h1 ] $(element).addClass("active"); $(element).removeClass("active"); $(element).text("hello world"); $(element).html("
<p>hello world</p>
"); $(element).val(""); // clear

ajax

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$.ajax({
url: "/api",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify(data),
})
.done(function (res) {
...
})
.fail(function (error) {
console.error(error.responseJSON);
})
.always(function () {
...
});