Stan Amsellem Stan Amsellem - 1 year ago 86
HTML Question

Can't extract the text of an html tag using jQuery

I am having trouble extracting content of an html tag through the chrome console. I think I am missing something pretty obvious but it's been half an hour I'm trying stuff and I can't make it work, so I'm asking help :)

I want to extract some code from that page:

Here's the html snippet I'm interested in:

<table id="rensjur">

I want to extract the content "DEEZER" of the second < td >. I am using the following:

$("#rensjur tbody td:nth-child(2)").text();

but this raises an error:
Uncaught TypeError: $(...).text is not a function(…)

However, when I call:

$("#rensjur tbody td:nth-child(2)")

It gives me the right HTML tag:


How can I get only "DEEZER" as a result ? What am I doing wrong with the
method ?

Answer Source

Use the innerHTML property; that will help.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download