JS 中的$(this) 理解

橙色阳光 2017-04-13 09:40:21


$("#tab_tj tr").each(function() {
var type = $(this).attr("type");
var zdzslx= $(this).attr("zdzslx");
var value = $("td", $(this)).eq(4).find(":first-child").val();
var guanlianzd=$(this).attr("guanlianzd");
if(guanlianzd=='null'){guanlianzd="";}
var xuzd=$("td", $(this)).eq(2).attr("xmemc") ;
var czlx=$("td", $(this)).eq(3).find("select").val();
if(type=='3' && guanlianzd=="" )
{
value = $("td", $(this)).eq(4).find("select option:selected").text();
}
if(guanlianzd!="" )
{
xuzd=guanlianzd;
}
if(type=="4" && zdzslx!="DATE"){
xuzd="to_date(" + xuzd +",'yyyy-mm-dd')";
}
var ljf = $("td", $(this)).eq(1).find("select").val();
if (value != "" || czlx=="7" || czlx=="9") {
if (ljf == "1") {
tj += "并且" + Getsmtj($(this), type,czlx);
sql += " and " + xuzd + Getczf(czlx, value,type);
}
else {
tj2 += "或者" + Getsmtj($(this), type,czlx);
sql2 += " or (" + xuzd+ Getczf(czlx, value,type) + ")";
}
}
});



var value = $("td", $(this)).eq(4).find(":first-child").val();

这个$(this) 是指 "td" 还是 上面的$("#tab_tj tr")。
怎样快速理解这些 this
...全文
378 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38299434 2017-04-13
  • 打赏
  • 举报
回复
这个this是代表tr,是遍历每一行的意思
打老虎zz 2017-04-13
  • 打赏
  • 举报
回复
“td” 是你在这个对象的函数里写的一个字符串 你觉得this(这个)是指的什么
functionsub 2017-04-13
  • 打赏
  • 举报
回复
这个$(this) 是指 "td" 还是 上面的$("#tab_tj tr")。 先回答问题,是 $("#tab_tj tr")中每次遍历的元素。 关于this的理解,正好有个帖子,你自己去看下吧。 点这里

87,917

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧