troubleshooting Question

Search Page For String Within ElementId

Avatar of deharvy
deharvy asked on
6 Comments2 Solutions265 ViewsLast Modified:
I need javascript code that will search through a particular elementid and then search for a string value within the text.

Here is an example of the page content:

<td id=attribute>Hair:</td><td  id=style>Blonde</td>
<td id=attribute>Eyes:</td><td  id=style>Brown</td>
<td id=attribute>Ht:</td><td  id=style>4'11"</td>
<td id=attribute>Wt:</td><td  id=style>130</td>


Here was my failed attempt:
var isBlonde = false;
		var body = gwndTarget.document.getElementById('style');
		for (var i=0; i<body.length; i++) {
  		if (body[i].indexOf("Blonde") > -1){
  			isBlonde = true;

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros