Anu
Anu

Reputation: 630

How to access the inner table element using jquery?

Hi I am not able find a solution to access the inner table element using its index value.I have two table a parent and child table i.e, outer table has a row within which there is a inner table. When I click a text box within the inner table it open up a div when I click that div it provides few data and that data must be sent to the currently clicked text box. I could do that for the outer table but not the inner table. I am using this code snippet to do for inner table

('#packageaddtable > tbody > tr > td > #packs tr:eq(' + rowIndex + ')').find(".start_time4").val(val);

And this is for outer table

$('#packageaddtable > tbody tr:eq(' + rowIndex + ')').find(".package_textbox").val(val);

Can someone please help me solve it? Please. Thanks in advance.

Here is a Fiddle demo that I have tried until now.

Upvotes: 1

Views: 208

Answers (1)

Mahendra
Mahendra

Reputation: 59

Try below code it may be helpful

function get_employee(val, indx) {
$('#packageaddtable > tbody > tr').contents().find('#packs tr:eq(' + rowIndex + ')').find(".start_time4").val(val); //here I could not reach the inner table element start_time4
console.log($('#packageaddtable > tbody > tr > td > #packs tr:eq(' + rowIndex + ')'));

}

Upvotes: 1

Related Questions