官方網(wǎng)站:
http://jquery.com/
jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing,
event handling, animating, and Ajax interactions for rapid web development
構(gòu)造函數(shù):
jQuery(expression,context)
jQuery(html)
jQuery(elements)
jQuery(fn)
jQuery()(也可以$())
$(document).ready作用:
$(document).ready():是在DOM結(jié)構(gòu)載入完后執(zhí)行的
window.onload:所有文件(整個(gè)網(wǎng)頁(yè))都加載完后執(zhí)行的
例如:
$(document).ready(function(){
alert("hello");
});
等同于
$(function(){
alert("hello");
});
開發(fā)中常用操作:
$('#element');//css id document.getElementByIdx("element")
$('.element');//css class
$('p');//html標(biāo)簽
$('#element').css({ "background-color":"yellow", "font-weight":"bolder" });//改變對(duì)象樣式
$("p").text("Some new text.");//改變對(duì)象文本
$("p").append("<b>hello</b>");//給對(duì)象添加內(nèi)容
$("img").attr({ src: "test.jpg", alt: "no content" });//改變對(duì)象文本
text,textarea值獲取:
$("#text_id").attr("value") 或者 $("#text_id").val()
checkbox值獲取:
$("#checkbox_id").attr("value")
var checked = $("input[@type=checkbox]:checked");
checked.size() == 1 ==>checked.val();
radio值獲取:
$("input[@type=radio][@checked]").val()
選中的值: $('input[@name=items][@checked]').val();
select值獲取:
$('#select_id').val()
選中的值:$("select[@name=items] option[@selected]").text();
Jquery FlexGrid:
具有分頁(yè)排序功能的表格控件
官方網(wǎng)站:http://www.flexigrid.info/
$(document).ready(function(){
grid= $("#flex-grid").flexigrid( {
url: 'xx.action',
dataType: 'json',//默認(rèn)為xml
method: 'POST',//默認(rèn)為post
colModel : [
{display: '編號(hào)', name : 'id', width : 40, sortable : true, align: 'center'},
{display: '姓名', name : 'name', width : 180, sortable : true, align: 'left'},
{display: '部門', name : 'dept', width : 120, sortable : true, align: 'left'}
......
],
buttons : [
{name: 'add', bclass: 'add', onpress : xxfunc},
{name: 'aelete', bclass: 'delete', onpress : xxfunc},
{separator: true}
],
searchitems : [