1 Replies - 394 Views - Last Post: 24 July 2014 - 11:12 AM

#1 danielchr99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-July 14

JavaScript - Getting element based on text found

Posted 24 July 2014 - 10:27 AM

Hi,

I need to search text on a page and select the element that contains that text. Here is my code

if (window.find) {
            while(found = window.find (key[index])) {
				if(found) {
					alert("found " + key[index] + " at an index of " + index)
					grabShoe(key, index, shoeData);
					++index;
				}
			}
        }



The text is found, I just have no clue how to get the element that contains the found text. The text that is found is highlighted in gray on the page. Any ideas?

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: JavaScript - Getting element based on text found

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 471
  • View blog
  • Posts: 1,729
  • Joined: 15-January 14

Re: JavaScript - Getting element based on text found

Posted 24 July 2014 - 11:12 AM

window.find won't help you get the element that contains the text. There are a few solutions here:

http://stackoverflow...lain-javascript
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1