Grab Table Element in Javascript

user3792038

I have a table in HTML that holds names, addresses and phone numbers.

In each row for that table, there is a link you can select that opens up a popover. When a popover is selected, I would like to store the name for that specific row. The class associated with a name is

<td class="du-orl-1"> Daniel </td>

I am trying to store that name in a class via Javascript but this just seems to store the whole array of data rather than the specific element:

var objectId = $(".du-orl-1").html($(this).html());

Any ideas on what I am doing wrong?

PeterKA

The following jQuery should be helpful:

var objectId = $(this).closest('tr').children('td.du-orl-1').text();

Should give you the name on the row where the link was clicked.

Note: this refers to the anchor element (link) that was clicked; therefore this piece of code should be inside the click handler.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to grab HTML table content with javascript?

From Dev

grab php output using javascript in table

From Dev

Python beautifulsoup grab table

From Dev

Grab from table values

From Dev

Accessing row element of table in Javascript

From Dev

Javascript grab the data from the table in the HTML and build an array of objects that contains the table data

From Dev

Grab element from json dump

From Dev

Xpath to grab corresponding child element

From Dev

Grab first <tr> & <a> if <table> contains <a>

From Dev

Grab HTML table using XML

From Dev

Grab one row from a table

From Dev

How to change the element at a row and column of a table in JavaScript

From Dev

How to remove css element that targets table with javascript

From Dev

Javascript find select element in a table cell

From Dev

javascript/jquery grab part of URL

From Dev

How to grab a CSS syntax with JavaScript?

From Dev

How to grab frame name with javascript?

From Dev

Grab all but one element in pandas series

From Dev

XML grab attribute from specific element node

From Dev

check array is exist if yes then grab last element

From Dev

Grab FindUploader object from UI element

From Dev

Not being able to grab element by ID using $(this)

From Dev

Grab the element with d3js

From Dev

Trying to grab a specific element with css selector

From Dev

Grab table from URL in Google App Script

From Dev

grab column elements from table header

From Dev

Grab cell value specifies an HTML table with jquery

From Dev

Grab Data on the Fly from Table HTML

From Dev

How do you grab an element relative to an Element instance with a selector?