html:
- HTML code
单月查询:<input type="radio" onclick="return sign();" name="select" /> 多月查询:<input type="radio" onclick="return more();" name="select" /> 查询日期: <span> <asp:DropDownList runat="server" ID="ddlYear"> </asp:DropDownList> <asp:DropDownList runat="server" ID="ddlMonth"> </asp:DropDownList> </span> <span id="endDate">―― <asp:DropDownList runat="server" ID="ddlYearEnd"> </asp:DropDownList> <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