+ -
当前位置:首页 → 问答吧 → jQuery浮动层取值问题

jQuery浮动层取值问题

时间:2009-07-31

来源:互联网

复制代码
  1. <script type="text/javascript">
  2. /* ================================================================
  3. This copyright notice must be untouched at all times.
  4. Copyright (c) 2008 Stu Nicholls - stunicholls.com - all rights reserved.
  5. =================================================================== */
  6. /* <![CDATA[ */
  7. $(document).ready(function(){
  8.     $('.hide').hide();
  9.     $('body').append('<div id="infoBacking"></div><div id="infoHolder" class="large"></div>');
  10.     $('#infoBacking').css({position:'absolute', left:0, top:0, display:'none', textAlign:'center', background:'#000', zIndex:'600'});
  11.     $('#infoHolder').css({left:0, top:0, display:'none', textAlign:'center', zIndex:'600', position:'fixed'});
  12.     if($.browser.msie){$('#infoHolder').css({position:'absolute'});}
  13.     //$('.more').mouseover(function() {$(this).css({textDecoration:'none'});} );
  14.     //$('.more').mouseout(function() {$(this).css({textDecoration:'underline'});} );
  15.     
  16.     $('.more').click(function(){
  17.         if ($('.' + $(this).attr("title")).length > 0) {
  18.         
  19.             browserWindow()
  20.             getScrollXY()
  21.         
  22.             if (height<totalY) { height=totalY; }
  23.         
  24.             $('#infoBacking').css({width: totalX + 'px', height: height + 'px', top:'0px', left:scrOfX + 'px', opacity:0.85});
  25.             $('#infoHolder').css({width: width + 'px', top:scrOfY + 25 + 'px', left:scrOfX + 'px'});
  26.             source = $(this).attr("title");
  27.         
  28.             $('#infoHolder').html('<div id="info">' + $('.' + source).html() + '<p class="clear"><span class="close">关闭</span></p></div>');
  29.         
  30.             $('#infoBacking').css({display:'block'});
  31.             $('#infoHolder').show();
  32.             $('#info').fadeIn('slow');
  33.         }
  34.         
  35.         $('.close').click(function(){
  36.             $('#infoBacking').hide();
  37.             $('#infoHolder').fadeOut('fast');
  38.         });
  39.     });
  40.     
  41.     /* find browser window size */
  42.     function browserWindow () {
  43.         width = 0
  44.         height = 0;
  45.         if (document.documentElement) {
  46.             width = document.documentElement.offsetWidth;
  47.             height = document.documentElement.offsetHeight;
  48.         } else if (window.innerWidth && window.innerHeight) {
  49.             width = window.innerWidth;
  50.             height = window.innerHeight;
  51.         }
  52.         return [width, height];
  53.     }
  54.     /* find total page height */
  55.     function getScrollXY() {
  56.         scrOfX = 0;
  57.         scrOfY = 0;
  58.         if( typeof( window.pageYOffset ) == 'number' ) {
  59.             scrOfY = window.pageYOffset;
  60.             scrOfX = window.pageXOffset;
  61.         } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
  62.             scrOfY = document.body.scrollTop;
  63.             scrOfX = document.body.scrollLeft;
  64.         } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
  65.             scrOfY = document.documentElement.scrollTop;
  66.             scrOfX = document.documentElement.scrollLeft;
  67.         }
  68.         totalY = (window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null);
  69.     
  70.         totalX = (window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null);
  71.         
  72.         return [ scrOfX, scrOfY, totalY, totalX ];
  73.     }
  74.     return false;
  75.     }
  76. );
  77. /* ]]> */
  78. </script>

我用这段代码来实现浮动,浮动的页面是:
复制代码
  1. <div class="page11 hide ">
  2. <div id="page">
  3.   <div class="page1">
  4.     <div class="centert">
  5.       <div class="rt"><img src="images/on.jpg" width="10" height="10" /></div>
  6.     </div>
  7.     <div class="center0"><span class="a2">莆田迷</span>,请填写以下资料:<br />
  8.       以下资料不对外公开!便于申请联系。</div>
  9.     <div class="center">
  10.   
  11.     <table width="480" border="0" align="center" cellspacing="0">  
  12.       <tr>
  13.         <td width="20%" align="right" class="a">申请人姓名:</td>
  14.         <td width="77%"><input name="applyname" type="text" value="11" size="36" id="applyname"/>        </td>
  15.       </tr>
  16.       <tr>
  17.         <td align="right" class="a">电话号码:</td>
  18.         <td><input name="applynum" type="text" size="36" id="applynum" value="22" /></td>
  19.       </tr>
  20.       <tr>
  21.         <td align="right"><span class="a"> 手机号码:</span></td>
  22.         <td><input name="applytel" type="text" value="" size="36"  id="applytel"/></td>
  23.       </tr>
  24.       <tr>
  25.         <td colspan="2"><div class="a3">以下资料对外公开!</div></td>
  26.         </tr>
  27.       <tr>
  28.         <td align="right" valign="top" class="a">商家名称:</td>
  29.         <td><input name="shopname" type="text" value="" size="36" id="shopname"/></td>
  30.       </tr>
  31.       <tr>
  32.         <td align="right">联系电话:</td>
  33.         <td class="b"><input name="shopnum" type="text" value="" size="36" id="shopnum"/></td>
  34.       </tr>
  35.       <tr>
  36.         <td align="right">QQ号码:</td>
  37.         <td><input name="qq" type="text" value="" size="20" id="qq"/></td>
  38.       </tr>
  39.       <tr>
  40.         <td align="right">详细地址:</td>
  41.         <td><input name="shopaddr" type="text" value="" size="36" id="shopaddr" /></td>
  42.       </tr>
  43.       <tr>
  44.         <td align="right" valign="top">商家简介:</td>
  45.         <td><span class="b">
  46.           <textarea name="shopintro" cols="38" rows="5" id="shopintro"></textarea>
  47.         </span></td>
  48.       </tr>
  49.       <tr>
  50.         <td align="right" valign="top">商家活动:</td>
  51.         <td><span class="b">
  52.           <textarea name="shopactive" cols="38" rows="5" id="shopactive"></textarea>
  53.         </span></td>
  54.       </tr>
  55.        <tr>
  56.         <td align="right" valign="top">商家LOGO:</td>
  57.         <td><span class="b">
  58.           <input type="file" name="shopimageaddr" id="shopimageaddr" id="shopimageaddr"/>
  59.         </span></td>
  60.       </tr>
  61.       <tr>
  62.         <td> </td>
  63.         <td><input name="Submit" type="button" id="input1" value="提 交" onclick="save()" /></td>
  64.       </tr>
  65.     </table>
  66.     </div>
  67.   </div>
  68. </div>
  69. </div>


在浮动状态时,当我点提交的时候,取不到我当前输入的值,请问这是为什么,我要什么解决?请各位大侠帮帮忙.谢谢
$("#applyname").val()
[ 此帖被youzlm在2009-08-01 08:38重新编辑 ]

作者: youzlm   发布时间: 2009-07-31

自顶一下.

作者: youzlm   发布时间: 2009-08-01

用firebug看看吧...

作者: jamix   发布时间: 2009-08-01

对于浮动层所进行的jquery操作多写在一个function里面,例如:
$(document).ready(function(){

       test();
});

function test(){
//对浮动层操作

}

作者: lichun   发布时间: 2009-08-05

相关阅读 更多