[英]how to get a particular cell value from dynamic table using javascript
I have a table showing records from database. 我有一张表,显示数据库中的记录。 There is a dropdown for selecting a particular user in each row.
在每一行中都有一个用于选择特定用户的下拉菜单。 On change, it should show the corresponding values of the new user.
更改后,它应显示新用户的相应值。
When I'm selecting a particular user from the dropdown, it should match the col1 and col2 value with the user selected and return col3 value. 当我从下拉列表中选择特定用户时,它应将col1和col2值与所选用户匹配,并返回col3值。 What I want is to get the col1 and col2 value of that particular row.
我想要的是获取该特定行的col1和col2值。 How can I do it ?
我该怎么做 ? Please help me.
请帮我。
You want to use live('click', function()
. This will apply on dynamically created elements. 您要使用
live('click', function()
,这将应用于动态创建的元素。
For example, you may try something like; 例如,您可以尝试类似的方法;
$('#your_table_id .some_class_in_a_row_to_click').live('click', function(){
$(this).siblings().each(function(){
var column = $(this).find('.some_class_for_column_with_data');
var data = column.text();
alert(data);
});
});
You may apply this on a table having some columns. 您可以将其应用于具有某些列的表。 Clicking on some column with class
some_class_in_a_row_to_click
will alert text on another column in that row having class some_class_for_column_with_data
单击具有
some_class_in_a_row_to_click
类的某列将提醒该行中具有some_class_for_column_with_data
类的另一列上的文本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.