Custom JavaScript To Control UI Elements in Microsoft Dynamics
This isn't the easiest functionality to get working, but it's fairly easy to make happen once you understand the process. As of Dynamics 2016 it requires hooking into a custom object model, and not directing manipulating the DOM. More on that to follow.
Just Say No To The DOM
Unfortunately for the web developer, who likes to interact with a website via JavaScript with the DOM, Microsoft Dynamics has disabled access on all fronts, meaning document.getElementById and any variation of that in jQuery does not provide access to the DOM element on the screen.
There are a few blogs out there written back in 2011 detailing this issue with a DOM-related solution, but that no longer works. This is Microsoft's Official statement:
For most script development work outside of Microsoft Dynamics CRM, developers may be accustomed to referring to page elements by using the document.getElementById method. For Microsoft Dynamics CRM form scripts this method is not supported. It is important to recognize that the attribute stores the data and the control is simply the presentation of the attribute in the form. For controls bound to attributes you may need to adjust the way you are accustomed to accessing data in the form.
Managing the Dynamics UI With The Xrm.Page Object Model
To provide developers with a better system for controlling the UI, the DOM, and the data they represent, Microsoft has given us the Xrm.Page object model. This provides access to the data itself, and controls over the UI elements.