I\'m new to JQuery and really struggling how to perform the query I want.
I\'m using SharePoint, and the when using the External Data Column and set it to required field
$('span.ms-error:contains("External Data")').hide();
If you know for sure that these span
's are inside a certain table
or a div
then target it specifically inside those to make the script perform better.
eg.
$('.ms-usereditor span.ms-error:contains("External Data")').hide();
Here's more optimised and faster approach:
$(".ms-usereditor span[class^='ms-error']:contains('External Data')").hide()
And additionally, this syntax works as a charm when you require a sort of regex pattern to find all matching nodes or nodes with similar classnames. Suppose, you need to find something .ms-error-1 .ms-error-abc. So, same syntax works and even better you could do like this:
$(".ms-usereditor span[class^='ms-error-']:contains('External Data')").hide()
var spans = $('.ms-error');
spans.text(''); // clear the text
spans.hide(); // make them display: none
spans.remove(); // remove them from the DOM completely
spans.empty(); // remove all their content