js調用jquery函數
jquery中的函數寫法:
$.fn.showMsgByPage=function(){}
js中調用:
$().showMsgByPage();
js獲取jquery中函數的返回值
$.fn.msgBoardCount=function () {
//從數據庫中取出數據顯示在HTML頁面
var result;
$.ajax({
url:"...", //請求的url地址
dataType:"json", //返回格式爲json
type:"post",
async:false,
success:function (data) {
result = data;
}
})
return result;
}
注意:要加上async:false;
然後就可以直接
var x = $().msgBoardCount();
jQuery零碎知識點
1.獲取孩子節點的數量
$().children.length