views:

68

answers:

1

Morning All,

Previously I have been using

$("#WebPartWPQ2 .ms-formtable tr:contains('lblName')> td").toggleClass('changedetails'); 

to customise a sharepoint list form, this has worked fine, (I have looked into alternative solutions to improve performance before but seem to achieve similar results)

Is there a selector for <nobr> in jquery

I have this working although I need it to match exactly rather than match if "contains".

$("#WebPartWPQ2 .ms-formlabel nobr:contains('Change Owner')").toggleClass('changedetails');

Thanks in advance Gary

+2  A: 

You can combine it with .filter() to check an exact match, like this:

$("#WebPartWPQ2 .ms-formlabel nobr").filter(function() {
  return $.text([this]) === "Change Owner";
}).toggleClass('changedetails');

The $.text() call is calling jQuery.text directly (calling Sizzle really), rather than making a new jQuery object for each <nobr> we're checking.

Nick Craver
Thanks Nick i will give this a go.
Gary
Hi Nick,I'm afraid this does not seem to work, there are no errors indicated in the JavaScript console, so it appears to just be missing the cells. Any ideas? Many Thanks
Gary
@Gary - What does your markup look like?
Nick Craver
Apologies Nick I now have it working, thank you :)
Gary