jQuery事件加载
jQuery Events loads
我想在页面加载后显示#results
。但我不知道我应该使用什么事件。有什么帮助吗?
$(document).ready(function(){
//Live search
$("#search").on('keyup' ,function() {
//Input field value
var query = $(this).val();
$.post('search.php', { search: query}, function(cities) {
$('#results').stop(true,true).fadeIn(200).html(cities);
});//End ajax call
});//End on function
});//End document.ready state
您可以将其加载到文档就绪回调中
$(document).ready(function () {
//this method loads the results based on the passed query
function load(query) {
$.post('search.php', {
search: query
}, function (cities) {
$('#results').stop(true, true).fadeIn(200).html(cities);
}); //End ajax call
}
//Live search
var $search = $("#search").on('keyup', function () {
//Input field value
load($(this).val());
}); //End on function
//on page load call the load method with the value in seach field
load($search.val());
}); //End document.ready state
相关文章:
- 召回窗口加载事件 - javascript
- 仅加载事件序列
- cookie加载事件页面重定向
- 正在捕获动态更改其源的图像的加载事件
- 如何从vb.net中的页面加载事件中调用特定的javascript函数
- 在iframe中加载pdf时,iframe未触发加载事件
- 点击加载事件按钮
- jQuery-将加载事件附加到动态加载的元素
- 不;t使用ajax在fullcalender.js中加载事件数据
- 加载事件中的“太多递归”
- 每10秒调用一次页面加载事件
- jQuery"该参考文献“;加载事件后未设置
- ASP网格视图的重新加载事件
- 在点击和加载事件时播放暂停背景音频
- 引导模式加载事件
- 页面中的条件在卸载之前加载事件
- 如何在 asp.net 中的页面加载事件之前调用 JavaScript 确认对话框
- 位置.重新加载事件触发按钮单击事件
- iframe 加载事件中的 setTimeout 似乎没有像预期的那样等待 x 秒
- 图像加载事件未触发