I am using M.Qassas' "Show / Hide fields based on choice field selection using JQuery in SharePoint 2013" and I've stumbled across an issue. When my Titles have a Full Stop (.) in them the script will not work as wanted. I'll attach my code below. Has anyone else had this experience before and a work around for it?

<script type="text/javascript">
jQuery('.ms-metadata').each(function(i,obj){var dest = jQuery(obj).parents('tr:first').find('td.ms-formlabel'); jQuery(dest).append('<br>');jQuery(obj).appendTo(dest);})
//Show/hide columns based on Drop Down Selection
$("select[title='2.18 Private Sector Interest']").change(function() {
if ($("select[title='2.18 Private Sector Interest']").val() != "Yes")
$('nobr:contains("2.18a Details of Private Sector Interest")').closest('tr').hide();
$('nobr:contains("2.18a Details of Private Sector Interest")').closest('tr').show();
  • 1
    "." will be considered as a CSS class name in jQuery selectors so you might need to change them with empty string Commented Dec 14, 2017 at 10:03
  • @ArsalanAdamKhatri Sorry for asking what is probably a very basic question but what do you mean by empty string? Commented Dec 14, 2017 at 10:22
  • As Danny answered, escape the notation will resolve the issue. Commented Dec 14, 2017 at 11:58

1 Answer 1


Your jQuery selector doesn't work with CSS selector notation



You can escape the notation:



or use partial matching:



Note: You can show/hide/color Form fields without using jQuery, with vanilla JavaScript:

How to display and hide columns on Display form based on whether they have data or not

  • I'm not sure if I'm misunderstanding you but I've tried $("select[title='2\\.18 Private Sector Interest']") to no luck - I've updated the example above to the code that's currently not working. Commented Dec 14, 2017 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.