-
show
$('div').show()
$('div').show(1000, 'linear', function () {
console.log('我显示完毕')
})
-
hide
$('div').hide()
$('div').hide(1000, 'linear', function () {
console.log('我隐藏完毕')
})
-
toggle
$('div').hide()
$('div').toggle(1000, 'linear', function () {
console.log('动画执行完毕')
})
-
animate
$('.show').click(function () {
$('div').animate({
width: 500,
height: 300
}, 1000, 'linear', function () {
console.log('动画运动完毕')
})
})
-
stop
$('div').stop()
-
finish
$('div').finish()
发送 ajax 请求
-
发送 get 请求
$.get('./ajax.php', { id: 10 }, function (res) { console.log(res) }, 'json')
-
发送 post 请求
$.post('./ajax.php', { id: 10 }, function (res) { console.log(res) }, 'json')
-
综合发送 ajax 请求
$.ajax({
url: './ajax',
type: 'GET',
data: {},
dataType: 'json',
async: true,
success () {},
error () {},
cache: true,
context: div,
status: {},
timeout: 1000,
})
-
发送一个 jsonp 请求
$.ajax({
url: './jsonp.php',
dataType: 'jsonp',
data: { name: 'Jack', age: 18 },
success (res) {
console.log(res)
},
jsonp: 'cb',
jsonpCallback: 'fn'
})