2011-04-12 6 views
2

안녕하세요 얘들 아 저는 스팬에 텍스트를 표시하고 버튼을 클릭 할 때 스팬 컨트롤을 토글하는 페이지를 가지고 있습니다. 기본적으로 jquery를 사용하고 있습니다. IE와 firefox에서 작동하지만 Chrome에서 닫기 버튼을 클릭하면 전환 할 수 있습니다. 처음 클릭하면 작동하지 않지만 처음 클릭하면 작동합니다.jquery는 크롬에서 작동하지 않고 IE와 파이어 폭스에서 작동합니다.

하시기 바랍니다 조언, 코드

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <script type="text/javascript" src="Assets/JS/jquery.js"></script> 
    <script language="javascript"> 
     $.showmsg = function (msgEle, msgText, autoHide, isSuccess) { 
      var tblMsg; 
      var imgType; 
      if (isSuccess) { 
       imgType = "<img src='Assets/Images/icon_status_success_26x26.gif'/>" 
      } else { 
       imgType = "<img src='Assets/Images/icon_status_fail_26x26.gif'/>" 
      } 

      tblMsg = '<div id="container" style="width: 400px;"><b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b><div class="contain"><table width="100%" cellpadding="0" cellspacing="0" border="0" class=""><tr><td style="width:30px;" align="center" valign="middle">' + imgType + '</td><td>' + msgText + '</td><td style="width:30px;" align="center" valign="middle"><a href="javascript:void(0);" onclick="$(\'#' + msgEle + '\').toggle(50);"><img src="Assets/Images/hide-icon.gif" border="0" alt="Hide" title="Hide"/></a></td></tr></table></div><b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b></div>'; 
      $("#" + msgEle).html(tblMsg); 
      $("#" + msgEle).show(); 
      if (autoHide) { 
       setTimeout(function() { $('#' + msgEle).fadeOut('normal') }, 10000); 
      } 
     } 


     function Delete1() { 
      $.showmsg('spnMessage', "Deleted", false, true); 
     } 

    </script> 
    <style type="text/css"> 
     .rtop, .rbottom 
     { 
      display: block; 
     } 
     .rtop *, .rbottom * 
     { 
      display: block; 
      height: 1px; 
      overflow: hidden; 
     } 
     .r1 
     { 
      margin: 0 5px; 
      background: yellow; 
     } 
     .r2 
     { 
      margin: 0 3px; 
      background: yellow; 
     } 
     .r3 
     { 
      margin: 0 2px; 
      background: yellow; 
     } 
     .r4 
     { 
      margin: 0 1px; 
      height: 2px; 
      background: yellow; 
     } 
     .contain 
     { 
      background: yellow; 
      text-align: left; 
     } 
    </style> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <br /> 
    <br /> 
    <br /> 
    <table> 
     <tr> 
      <td> 
       <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClientClick="Delete1(); return false;" /> 
      </td> 
      <td> 
       <span id="spnMessage" style="display: none;"></span> 
      </td> 
     </tr> 
    </table> 
    </form> 
</body> 
</html> 

답변

2

이하입니다. 같은 페이지의 다른 장소가 잘 작동하기 때문에 HTML의 일부분과 관련이 있다고 가정합니다.

if($(#'element_id').css('display') == 'none'){ 
    $(#'element_id').show(); 
}else{ 
    $(#'element_id').hide(); 
} 
:

나는이 문제를 해결할 수 있었던 유일한 방법은 어떻게하는 것이 었습니다

관련 문제