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