Array variable inside contains()
-
- var good = [
- "Label1",
- "Label2",
- "Label3"
- ];
- var goodlen = good.length;
- var i;
- var x = good[i];
- for(i = 0; i < goodlen; i++){
- $("span:contains('"+ x +"')").hide();
- }
-
- <span class='xxx'>Label1</span>
- <span class='xxx'>Label2</span>
- <span class='xxx'>Label3</span>
- I cant tell whats wrong here. I actually had it working and now Im not sure what happened. I cant figure out what the correct syntax is of putting the x variable inside the jquery line. if you look I have it with double quotes inside single quotes --just the + x + part I mean. Which I think is really odd but yet it changes to look correct(coloring) inside my editor. I checked stackoverflow and seen it done this way. This has me baffled. Any suggestions?