Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jQuery - Get all elements that end with a string

Posted on 2010-11-10
13
Medium Priority
?
1,108 Views
Last Modified: 2012-05-10
I need to know how to get, via jQuery, all elements in a page ( specifically table tr's ) that end with the string "_trcontent" and hide these elements.

I have tried several site such as http://stackoverflow.com/questions/609382/jquery-selector-id-ends-with which have similar requirements, to no avail.
0
Comment
Question by:sydron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 3
13 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 1000 total points
ID: 34108759
>Get all elements that end with a string.
<< all element >> ? You mean the id end

Use end selector : http://api.jquery.com/attribute-ends-with-selector/


jQuery('[id$="_trcontent"]').hide();

Open in new window

0
 

Author Comment

by:sydron
ID: 34108782
I tired that exact line of code and it did not work for me.
0
 
LVL 10

Expert Comment

by:hosneylk
ID: 34108829
how about this..
$('tr[id$="_trcontent"]').hide();

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:sydron
ID: 34108841
That did not work either.

I call each element directly, say $("#ele_tr_content").hide(); in the same area where i place the suggested code it seems to work.

I can't figure out why this is occurring.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34108850
So its tr_content with an underscore

_tr_content
_trcontent
0
 
LVL 10

Expert Comment

by:hosneylk
ID: 34108854
:)
0
 

Author Comment

by:sydron
ID: 34108856
My bad, it is _trcontent, my last post had it wrong.

 
0
 
LVL 10

Expert Comment

by:hosneylk
ID: 34108885
very strange... you're sure it's the exact code given above?

I have no idea if this will work but maybe you could give it a try.
$('#tableid tr[id$="_trcontent"]').hide();

Open in new window

0
 

Author Comment

by:sydron
ID: 34108891
Nope didn't work. Not sure whats going on .
0
 
LVL 10

Expert Comment

by:hosneylk
ID: 34108894
can you post the page source here?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34108895
can we see the page on the internet?
0
 

Author Comment

by:sydron
ID: 34108898
it is an intranet app. ill try your suggestions on a new clean page and see it if works.  thanks.
0
 

Author Comment

by:sydron
ID: 34108969
I figured it out. It was the version of jQuery i was using. Thanks guys.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question