开发者

How to hide a div if validation summary is available in javascript/Jquery

How to hide a div i开发者_StackOverflow中文版f validation summary is available in javascript/Jquery.


if(yourCondition){
  $("div#mydiv").hide()
}

what is validation summary?


var validationSummary = $('#<%= this.ValidationSummary.ClientID %>');
var myDiv = $('#myDiv');

if (validationSummary.length || validationSummary.is(':visible')) {
    myDiv.hide();
}

the cause for .is(':visible')is, that i don't know if an empty validationSummary renders the html-tags either or not. if not, you can leave out the .is()-check


you can use the HeaderText property to clean the HTML from inner ValidationSummary, seek in console for your content and you can see what change to erase.

I use this: create an element and call javascript function

ValidationSummary ID="vsGeral" runat="server" HeaderText="create element and call the HTML clean function destroy "

 var validationSummary = $('[id$=vsGeral]');

 if (validationSummary.length || validationSummary.is(':visible')) {

     function destroy() {

         $("[id$=vsGeral]").html("");

     }

 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜