Solved

jQuery - Get all elements that end with a string

Posted on 2010-11-10
13
1,102 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 250 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

626 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