0

I have a table like this, from this site Flipkart.com

<table cellspacing="0" class="specTable">
<tr><th class="groupHead" colspan="2">GENERAL FEATURES</th></tr>
<tr><td class="specsKey">Brand</td><td class="specsValue">SAMSUNG</td></tr>
<tr><td class="specsKey">Handset Color</td><td class="specsValue">Gold Platinum</td></tr>
<tr><td class="specsKey">Form</td><td class="specsValue">Bar</td></tr>
<tr><td class="specsKey">SIM Size</td><td class="specsValue">Nano SIM</td></tr>
<tr><td class="specsKey">Call Features</td><td class="specsValue">Loudspeaker</td></tr>
<tr><td class="specsKey">Model Name</td><td class="specsValue">Galaxy S7 Edge</td></tr>
<tr><td class="specsKey">Touch Screen</td><td class="specsValue">Yes</td></tr>
<tr><td class="specsKey">SIM Type</td><td class="specsValue">Dual Sim, LTE + LTE</td></tr>
</table>

Now I need to get the value Galaxy S7 Edge in this row from the table

<tr><td class="specsKey">Model Name</td><td class="specsValue">Galaxy S7 Edge</td></tr>

I have tried using this code

alert(String.valueOf($(".specsValue").eq(5)));

But i'm getting output as Object object

Karthik
  • 1,199
  • 2
  • 14
  • 23
  • `$('.specTable tr:nth-child(7)').find(".specsValue").text()` use this meaning in table at 7th row class specsValue its text – guradio Jul 30 '16 at 06:36
  • I have tried your answer, but i'm getting output like this. function String() { [native code] } – Karthik Jul 30 '16 at 06:40
  • i updated my comment..what output do you get? – guradio Jul 30 '16 at 06:41
  • [link](http://imageshack.com/a/img924/2787/gEH4NZ.png) I have used the updated code, but i'm getting next two rows information also. – Karthik Jul 30 '16 at 06:50
  • you have other element with class `specsValue` in row 7? can you give exact table markup? – guradio Jul 30 '16 at 06:52
  • [Table MarkUp](http://imageshack.com/a/img923/2739/tMMhHi.png) - Here is the table markup. – Karthik Jul 30 '16 at 07:05
  • [demo](https://jsfiddle.net/ahujm847/) looks good maybe you have other table with class `specTable`? – guradio Jul 30 '16 at 07:07
  • Yes, you have said right, i had 4 more tables with same class name "specTable" and in each table rows has same class name "specsValue". – Karthik Jul 30 '16 at 07:13
  • that is why you are getting other value... if the the table you want to get the `Galaxy S7 Edge` is the first one use `$('.specTable:nth-child(1) tr:nth-child(7)').find(".specsValue").text()` just change number in `'.specTable:nth-child(1)` depending on the table if first or secon etc... – guradio Jul 30 '16 at 07:17
  • I have update the code what you have giving, but i'm getting an empty alert. – Karthik Jul 30 '16 at 07:20
  • check this [demo](https://jsfiddle.net/ahujm847/1/) – guradio Jul 30 '16 at 07:22
  • I have uploaded the code in jsfiddle please have a look at the structure of the code having starting div and ending div tag. [demo](https://jsfiddle.net/krthk08/L6hdxygf/). Thank you Mr.guradio – Karthik Jul 30 '16 at 07:35
  • use `2` try this `$('.specTable:nth-child(2) tr:nth-child(7)').find(".specsValue").text()` check [demo](https://jsfiddle.net/L6hdxygf/1/) – guradio Jul 30 '16 at 07:39
  • Works like a charm sir. Thank you very much for your patience. – Karthik Jul 30 '16 at 07:47
  • np mate glad to help :) happy coding – guradio Jul 30 '16 at 07:50

0 Answers0