Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1131
  • Last Modified:

jQuery - Get all elements that end with a string

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
sydron
Asked:
sydron
  • 6
  • 4
  • 3
1 Solution
 
leakim971PluritechnicianCommented:
>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
 
sydronAuthor Commented:
I tired that exact line of code and it did not work for me.
0
 
hosneylkCommented:
how about this..
$('tr[id$="_trcontent"]').hide();

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
sydronAuthor Commented:
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
 
leakim971PluritechnicianCommented:
So its tr_content with an underscore

_tr_content
_trcontent
0
 
hosneylkCommented:
:)
0
 
sydronAuthor Commented:
My bad, it is _trcontent, my last post had it wrong.

 
0
 
hosneylkCommented:
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
 
sydronAuthor Commented:
Nope didn't work. Not sure whats going on .
0
 
hosneylkCommented:
can you post the page source here?
0
 
leakim971PluritechnicianCommented:
can we see the page on the internet?
0
 
sydronAuthor Commented:
it is an intranet app. ill try your suggestions on a new clean page and see it if works.  thanks.
0
 
sydronAuthor Commented:
I figured it out. It was the version of jQuery i was using. Thanks guys.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 6
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now