0

I'm trying to get information from a table I have populated into. I got this code :

> dataHtml += `<tr onclick="getRowDetails(this)" class='accordion'
> id="accordion"> onclick="newAssign(this)"><td>${course.Year}</td><td>${course.Semester}</td><td>${course.Route}</td><td>${course.CourseName}</td></tr>`;

and once the row is clicked this function is triggered:

function getRowDetails(value) {
            console.log("showing this")
            console.log(value)
        }

and once I click on the row i see the following information: enter image description here

My question is how do I approach this if I want to show the value "Big Data" only?

thanks !!

3
  • Assuming value contains HTML element, than you can simply select it's child: value.children[3] Commented May 22, 2022 at 17:40
  • Thanks alot !! It's working for me , by any chance do you know how can I remove the "<td>" out of the output? (the output is <td>Big Data<td> Commented May 22, 2022 at 17:57
  • just like any other DOM manipulations, by using removeChild() Commented May 22, 2022 at 18:03

2 Answers 2

2

Like this:

      function getRowDetails(value) {
        /* for (let i = 0; i < e.children.length; i++) {
          console.log(e.children[i].textContent);
        } */
        console.log(value.children[3].textContent);
      }
Sign up to request clarification or add additional context in comments.

Comments

0
var row = $(value); 
var text = '';
for (var i = 0, col; col = row.cells[i]; i++) {
    if(col.innerHTML == 'Big Data')
        text = col.innerHTML;
          alert(text);
        }

the syntax may be wrong, i didn't try but i guess you can solve it like this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.