在C#div中充当runat服务器所以无法在javascript

在C#div中充当runat服务器所以无法在javascript

本文介绍了在C#div中充当runat服务器所以无法在javascript中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div id="imgd" class="active" runat="server">
                                <img src="images/logo3.png" height="35" alt="Porto Admin" />
                            </div>
                            <div id="imgl" class="dnone" runat="server">
                                <img src="images/logo4.png" height="35" alt="Porto Admin" />
                            </div>













<div class="panel-body">
                                           <div id="demo-form" class="form-horizontal mb-lg">
                                               <div class="form-group mt-lg">
                                                   <div class="col-sm-3">
                                                       <input class="fixed dark btn btn-primary" type="button" id="btnd" value="Dark" onclick="changeCSS();" />
                                                   </div>
                                                   <label class="col-sm-6 control-label" style="text-align: center;"><b>Background Color </b></label>
                                                   <div class="col-sm-3">
                                                       <input class="fixed btn btn-info" type="button" id="btnl" value="Light" onclick="change();" />
                                                   </div>
                                               </div>
                                           </div>
                                       </div>


 <script type="text/javascript">>

          function changeCSS() {
              document.getElementById("divHTML").className = "fixed dark";

              document.getElementById('<%=imgl.ClientID%>').style.display = "none";
              document.getElementById('<%=imgd.ClientID%>').style.display = "block";

          }

        </script>

        <script>
            function change() {
                document.getElementById("divHTML").className = "fixed";
                document.getElementById("imgd").style.visibility = "hidden";
                document.getElementById("imgl").style.visibility = "visible";
                document.getElementById("imgl").className = "ldisp";
            }
        </script>

推荐答案

<div id="imgd" class="active"  runat="server">
	<img src="images/logo3.png" height="35" alt="Porto Admin" />
</div>




<script>
function change() {
	document.getElementById("<%=imgd.ClientID%>").style.visibility = "hidden";
}
</script>


这篇关于在C#div中充当runat服务器所以无法在javascript中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 01:56