使用JavaScript连续获取第一个单元格 [英] Get first cell in a row using JavaScript
本文介绍了使用JavaScript连续获取第一个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我代码的前几行:
$('tr.existing_users > td').click(function(e){
var target_name= e.target;
var first_element=target_name.parent.first; //wrong
e.target
给了我一个td
,它包裹在tr
中.我想阅读该tr
行中第一个元素的innerHTML
.我该怎么做呢? (我当然也对jQuery解决方案感兴趣)
e.target
gives me a td
which is wrapped in a tr
. I want to read the innerHTML
of the first element in that tr
row. How do I do this? (I'm also interested in jQuery solutions of course)
推荐答案
var first_element = $(this).parent().children().eq(0);
var first_html = first_element.html();
这篇关于使用JavaScript连续获取第一个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文