日期:2014-05-16  浏览次数:20343 次

span隐藏后再次显示,位置变了…
html:
HTML code

单月查询:<input type="radio" onclick="return sign();" name="select" />
                    &nbsp;&nbsp;&nbsp;&nbsp; 多月查询:<input type="radio" onclick="return more();" name="select" />
                    &nbsp;&nbsp;&nbsp;&nbsp; 查询日期: <span>
                        <asp:DropDownList runat="server" ID="ddlYear">
                        </asp:DropDownList>
                        &nbsp;&nbsp;
                        <asp:DropDownList runat="server" ID="ddlMonth">
                        </asp:DropDownList>
                    </span>&nbsp; <span id="endDate">——&nbsp;
                        <asp:DropDownList runat="server" ID="ddlYearEnd">
                        </asp:DropDownList>
                        &nbsp;&nbsp;
                        <asp:DropDownList runat="server" ID="ddlMonthEnd">
                        </asp:DropDownList>
                    </span>


js

JScript code


<script type="text/javascript" language="javascript">
        function sign() {
            var newSpan = document.getElementById("endDate");
            newSpan.style.display = "none";
        }
        function more() {
            var newSpan = document.getElementById("endDate");
            newSpan.style.display = "block";
        }
    </script>




初始效果是在一行,点击多月查询时结束年月另起了一行…这是为什么?查看源文件没发现什么区别…


------解决方案--------------------
newSpan.style.display = "block";
block就是显示并独占一行的,如果要显示并不独点一行,可以指定float,
或者有预留空间的话,用visibility:visible /hidden 显示隐藏
------解决方案--------------------
newSpan.style.display = "inline";
不要block