0

i have a complete page coming in my success message and it is comingas complete html, inside it it has

<table><tr><td><font class="abc"><a></a> - these are multiple </font></td></tr></table>

now i am trying to get the paging contents based upon the find of jquery to get the inner contents of the font tag

trying like this:

$("#mydiv").find("table>tr>td>font").html();

but that does not seems to be working

Thanks everyone for answers, To Update here #1

to make sure i get the element i need the text [pages] is written inisde te font tag, so want to have a check if the fonr has pages then extraxt whole content inside the font

Thanks

cater
  • 11
  • 4
  • 1
    Do the answers to this question address your problem: http://stackoverflow.com/questions/5568859/why-doesnt-table-tr-td-work-when-using-the-child-selector? Incidentally, the [`` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font) is deprecated, please consider using CSS instead. – David Thomas Feb 20 '15 at 18:45
  • You shouldn't be using the `font` tag. It's outdated(unsupported in HTML5) and is not meant to be used the way you are using it here. – APAD1 Feb 20 '15 at 18:46
  • I wrote a jQuery selector tester once upon a time that could come in useful here http://joefitter.github.io/selector-tester/#/ – Joe Fitter Feb 20 '15 at 18:56
  • can i add a check like this: which returns me true and false: `var paging = $("#mydiv").find('table>tbody>tr>td>font:contains("Pages")');` – cater Feb 20 '15 at 19:14

6 Answers6

0

You can find the font tag with class "abc" with the following-

$("#mydiv").find('.abc')

Now, to get the content of this tag, you can do-

$("#mydiv").find('.abc').html()
Chirag Mongia
  • 545
  • 4
  • 12
0

It does not work, because the <table> Element is the root node for your snippet. Hence, .find() can't do its job, since it only searches child nodes.

.find("tr>td>font").html();

would work for that reason.

jAndy
  • 231,737
  • 57
  • 305
  • 359
0

After inserting in your html DOM your table has additional tbody inside your table, so your selector doesn't work.

So you can do it with another selector:

$("#mydiv").find("tbody > tr > td > font").html();
rakhmanoff
  • 349
  • 1
  • 3
  • 13
0

You can do:

$("table").find(".abc").html();
Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
Vishal Wadhawan
  • 1,085
  • 1
  • 9
  • 11
0

If you don't want to use the class to target the element, then slightly change the select:

$("#mydiv").find("table div>tr>td>font").html()
DAB
  • 93
  • 1
  • 7
0

You are missing the <tbody> tag, which the browser renders (to correct incorrect html). Also, the <font> tag is deprecated, so you may want to avoid using it.

Try this:

$("#myDiv").find("table > tbody > tr > td > font ").html();

See this demo

Ted
  • 14,757
  • 2
  • 41
  • 58