Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

span element has text with spaces like
HTML
<span>code project</span>


I have text "codeproject",how to find span element with text which has no spaces.

My requirement I need to find parent element of span.

JavaScript
$('span.contains("code project")').parent();
Its working.

But how find element with text("codeproject") which do not have spaces.

Thanks in advance.
Posted

1 solution

In exact same way.

See also: http://api.jquery.com/category/selectors[^].

—SA
 
Share this answer
 
v2
Comments
Prasannala 29-Jan-15 1:42am    
you are saying $('span.contains("codeproject")').parent(); But element is not finding. because span element text has spaces. I have text without spaces.
Sergey Alexandrovich Kryukov 29-Jan-15 1:58am    
No, the space doesn't matter. Check up everything properly. Maybe, there is no such text, or something else.
Well, give as exact example of what's not working. Minimal and self-contained.
—SA
Prasannala 29-Jan-15 2:00am    
ok.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900