31/10/2011

jQuery 'contains' oddity

Imagine you are hiding a field in SharePoint

$('nobr:contains("Email")').closest('tr').hide();

The 'contains' function should act as a wild card - so if you have a bunch of fields beginning with 'Email' then you would imagine the above script will hide them all.

It appears - and this is a SharePoint only quirk - that if your string has more than one space e.g. Email My Manager it intemittently misses the string and doesn't pick it up for hiding.
Still trying to work this one out.....
My tip would be to use the full string in the contains element
Odd!

No comments:

Post a Comment