Jquery remove text from span

后端 未结 3 682
[愿得一人]
[愿得一人] 2021-02-04 15:31

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

相关标签:
3条回答
  • 2021-02-04 15:51

    $('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();

    0 讨论(0)
  • 2021-02-04 15:59

    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()
    
    0 讨论(0)
  • 2021-02-04 16:02
    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
    
    0 讨论(0)
提交回复
热议问题