$(“#testul”).append(li);
/*寻找新增的id为idx(其中x为计数器var id的值)的li节点下的a节点,并且把其中的元素修改为你好x,jquery里面的.html相当于javascript里面的innerHTML*/
$(“#id”+id.toString()).find(“a”).html(“你好”+id);
/*设置此a元素的href属性为,jqrec.html=“你好”+id,由于链接中不可以带中文,所以用两次escape将其编码为utf-8编码,用一次会出现bug,后面的unescape获取不了,不知道为什么*/
$(“#id”+id.toString()).find(“a”).attr(“href”,”./jqrec.html?text=”+escape(escape(“你好”+id)));
/*设置滚动条随着testul的所在高度滚动,这段代码在ie8以下会失效*/
$(“body”).scrollTop($(“#testul”).height());
});
/*clear按钮点击事件*/
$(“#clear”).click(function (){
/*把testul下面的所有元素清空,计数器清零*/
$(“#testul”).empty();
id=0;
});
/*findmyfather行内文本点击事件*/
$(“#findmyfather”).click(function(){
/*this代表被按的findmyfather,取其上一级父节点的id*/
thisid=$(this).parents().attr(“id”);
alert(“我的父节点是:”+thisid);
/*这样可以往前寻找第一个div元素的id*/
thisid=$(this).parents(“div”).attr(“id”);
alert(“我的第一个div父节点是:”+thisid);
/*这样可以往前寻找第二个div元素的id*/
thisid=$(this).parents(“div”).parents(“div”).attr(“id”);










