奇怪的JavaScript
时间:2010-09-20 来源:bzuit
这些天快让js脚本给搞晕了,本来感冒就晕。为了让用户得到更好的视觉效果我用了Jquery。函数调用之类的还没有什么问题。但是最后的显示却是一个大问题。
<style type="text/css"> .topdiv{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; background-color:gray; z-index:1001; } .belowdiv { display: none; position: absolute; top: 25%; left: 25%; width: 50%; padding: 16px; border-top:solid,16px,red; border-left:1px; border-right:1px; border-bottom:1px; background-color: white; z-index:1002; overflow: auto; } </style> <script type="text/javascript"> function comeIn() { $("#top").fadeIn("slow"); $("#below").fadeIn("slow"); } //隐藏 function takeChectedId() { $("#top").fadeOut("slow"); $("#below").fadeOut("slow", function () { var chekcBoxList = $(":checkbox:checked"); var result = ''; var resultName = '' chekcBoxList.each(function () { result = result + $(this).val() + ','; resultName = resultName + this.name + ','; }); alert(resultName); //$('#<% =CheckedList.ClientID %>').val(resultName); }); } </script>
<div id="top" class="topdiv"><a href = "javascript:void(0)" onclick = "takeChectedId()">关闭</a> <div style=" float:right"><input type="image" src="../images/btn_close.png" onclick = "takeChectedId()" /></div> </div> <div id="below" class="belowdiv"> <input runat="server" id="CheckedList" type="hidden" value="hiddentest" /> <table> <asp:Repeater runat="server" ID="ContentsItem"> <ItemTemplate> <%# Container.ItemIndex%3==0?"<tr>":"" %> <td><input type="checkbox" name='<%# Eval("Name") %>' value='<%# Eval("Id") %>' /> <%# Eval("Name") %></td> <%# Container.ItemIndex%3==2?"</tr>":"" %> </ItemTemplate> </asp:Repeater> </table> </div>
就是这个了,可以看到有两个地方调用了takeCheckedId(),就是这个地方出问题了,
<div id="top" class="topdiv"><a href = "javascript:void(0)" onclick = "takeChectedId()">关闭</a>正常。
<div style=" float:right"><input type="image" src="../images/btn_close.png" onclick = "takeChectedId()" /></div>这个就不正常了,但是这个在调试的时候可以!!真tm的郁闷!!
相关阅读 更多 +