A better jQuery selector to hide a row in a SharePoint 2010 Edit Form

In the past, I had used this code to hide a row in a SharePoint Edit Form (EditForm.aspx):


The problem with this is that if you have two fields that contain the text “Attendees” (For example “NewAttendees” & “OldAttendees”), then it matches both of them (this always seems to to be an issue for us). So I did a little research and I found a better way to select a row (I think this was my original source)

Here is my new/better way to match a row:

 $('nobr').filter(function () { return $(this).text() === 'Attendees' }).closest('tr').hide();

If it was a required field, it would be:

 $('nobr').filter(function () { return $(this).text() === 'Attendees *' }).closest('tr').hide();

Hope that helps someone.


4 Responses to A better jQuery selector to hide a row in a SharePoint 2010 Edit Form

  1. Marc Anderson January 29, 2014 at 12:14 pm #

    Even better, make yourself a little utility function so that you can call it for multiple columns. This one works whether the column is required or not. You never know when someone might tick that Required box!

    function hideRow(c) {
    var x = $(“.ms-formlabel nobr”).filter(function () {
    return $(this).contents().eq(0).text() === c;


  2. jbmurphy January 29, 2014 at 12:17 pm #

    Great idea! Thanks.

  3. Kep March 27, 2014 at 3:33 pm #

    How do you go about hiding a row that doesn’t have any hard coded text to reference in the nobr code?

    I’m new to jquery and I’ve edited my userform to utilize the field description instead of the FieldName, but I can’t figure out how to reference the field description as the row to hide.

    Any help appreciated.

  4. Dirk B. December 4, 2014 at 1:53 am #

    Very helpful, thanks!