www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Get Text from Table Cell with Dropdown

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    16

    resolved [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?

  2. #2
    Join Date
    Dec 2012
    Posts
    137
    You could use a regular expression to extract the part that you need from the cell.

    Code:
    var text = tablecell.text().match(/\/select> (.*)/)[1];
    Assuming that the text comes after the select field, or use this pattern if the text is before the select field.

    Code:
    /(.*) <select>/

  3. #3
    Join Date
    Jul 2013
    Posts
    16
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles