[RESOLVED] Get Text from Table Cell with Dropdown
I want to get text from a table cell that has both text and a dropdown with text in it and when I use tablecell.text() it returns the text from the dropdown along with the cell text. What do I do so that it only returns the cell text?
You could use a regular expression to extract the part that you need from the cell.
Assuming that the text comes after the select field, or use this pattern if the text is before the select field.
var text = tablecell.text().match(/\/select> (.*)/);
I did tablecell.clone().children().remove().end().text() which cloned the cell, removed the select element, then returned the text remaining in the cell. The regex method seems cleaner, but I must have typed it wrong since it didn't work for me. Either way, the problem is solved.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread