jQuery and JavaScript selectors in SharePoint

Just a quick reminder of the various selectors that work well on SharePoint 2010 list forms. For SharePoint 2010 custom list forms, doc mode 8,9 on your master page, use jQuery selectors and use jQuery 1.11.

JavaScript selectors for SharePoint 2013 list forms, doc mode 10 and newer on your master page

var personnelTypeEl = document.querySelector('[title="Category"]'); 
var personnelType = personnelTypeEl.value;
var statusOptions = document.getElementsByClassName("statusOptions");
var statusOptionsLength = statusOptions.length;
if (personnelType === "Tasking") {
for (var i = 0; i < statusOptionsLength; i++) { statusOptions[i].style.display= "table-row"; }
} else {
for (var i = 0; i < statusOptionsLength; i++) { statusOptions[i].style.display= "none";
} } });
var personnelType = document.querySelector('[title="Category"]'); personnelType.addEventListener('click', function() {
//some code here
});

jQuery selectors for SharePoint 2010 list forms, docmode 8,9 on your master page

var personnelType = jQuery('select[title="Category"]').val();
var statusOptions = jQuery('.statusOptions');
jQuery(".statusOptions").css("display", "table-row");
jQuery(".statusOptions").css("display", "none");
jQuery(personnel).click(function(){ //some code here });

Leave a Reply