//obj 所有要添加mousedown事件的对象,jquery对象
//tag 列表的标签如li,tr
//向后台抛送用户点击日志
function addmousedownevent(obj,tag){
obj.mousedown(function(){
t=$("#type").val();
k=$("#keyword1").val();
p=$.trim($(".pages strong").eq(0).text());//取class是pages的元素下面的第一个strong标签里面的文本内容并去掉两端的空白
u=$(this).attr("href");//当前元素的href属性值
reg=/index/.php/?/;
is=(reg.exec(u))?1:0;
n=(t!='sjiaju')?$.trim($("div.title1 p strong").eq(0).text()):$.trim($("div.breadcrumbs2 p strong").eq(0).text());
n=n?n*1:0;
o=$(this).parents(tag).eq(0);//取当前元素的所有上级节点中指定的tag标签,并取第一个
po=(o.parent().find(tag).index(o))*1+1;//在o.parent所有tag的集合中,o的键值
$.ajax({
type :'post',
url :'/static/static_log.php',
data :'type='+t+'&keyword='+k+'&page='+p+'&url='+u+'&isqshow='+is+'&restot='+n+'&pos='+po
})//执行一个ajax
});
}
几个函数值得记录
parent()和parents()的区别
find()和filter()的区别
index()的用法,和返回值
jquery的选择器.