jquery页面弹窗及取值问题

来源:互联网 发布:华为手机优化设置 编辑:程序博客网 时间:2024/05/17 23:24

小结

$('a.dimission1').click(function(){   //<a Class=dimission1>

    $this = $(this);

 

<%

for(RamusStaffInfo staff:pl){

%>       

 <inputtype="hidden"id="staffId" value="<%=staff.getStaffId()%>"/>

 <ahref="#"class="dimission1"staffId="<%=staff.getStaffId()%>">aaa</a>

 

在一个循环遍历中,若用隐藏域方式传值,且拿$('#staffId').attr("value");

方式取值,则会取出都为循环中的第一个值。用$(this).attr("staffId");方式取值则不能取得该项的值,取出为undefined。若用第二个,在触发函数的同时传值,用$('#staffId').attr("value");取当前的值取出为undefined,用$(this).attr("staffId");可取到当前的循环项的值。

 

$(this).text();A标签中的内容值aaa


案例1:弹出新页面,限制大小,类似于窗口

//父页

<html>

    <head>

       <title>弹窗及取值 </title>

<linkrel="stylesheet"href="ui.all.css"type="text/css" charset="UTF-8"media="screen"/>

<scriptlanguage="javascript">

    $('a.dimission1').click(function(){

       $this = $(this);

        $staid = $(this).attr("staffId");

        $desc  =$(this).text();

        jewel = $('#jewel');

        warn="您确定要将编号为"+$staid+"的教师转为"+($desc=='离职'?"在职":"离职")+"";    

           if(confirm(warn)){

              alert($desc);

              if($desc=='在职'){

       $(jewel).dialog({   

           autoOpen:false,

           modal:true,      

           draggable:true,

           resizable:false,

           height:300,

           width:300,

           title:"",

           overlay: { opacity: 0.4,background:"black" }

             });  

       $('#jewel').dialog("open");

           varurl ="add.jsp?staffId="+$staid;//弹出页,添加

           send(url);}

           else{

            location.href="set.jsp?type=1&staffId="+$staid;//转向页,数据库处理

           }   }

    });

    functionsend(url){

      

       varajaxurl= url;

       $.ajax({

           type:"get",

           url:ajaxurl,

           cache:false,

           global:false,

          

           success: function(data){

               $('#jewel').empty();

               $('#jewel').html(data);

           }

      });

    }

 

});

 

</script>

    </head>

 

    <bodybgcolor="#FFFFFF">

       <h3align="center">

       O(∩_∩)O哈哈~

       </h3>

         <div id="jewel"></div>

       <divalign="center"class="a">

           <tableborder="1"cellspacing="0"cellpadding="4"class="a"width="100%">

          <tr><th>aaa</th></tr>

<%

 

long id =0;

for(a staff:pla){

    id=  staff.getStaffId();

%>

             

<tr><td><ahref="#"class="dimission1" staffId="<%=staff.getStaffId()%>">在职</a></td></tr>

<%

}

%>

           </table>

       </div>

    </body>

</html>

 

//add.jsp

<%

//获取staffId的值

%>

<html>

  <head>   

    <title>子页面,用于添加</title>

<metahttp-equiv="Content-Type"content="text/html; charset=utf-8">

<linkrel="stylesheet"href="xadx.css"type="text/css"media="screen"/>

  </head>

 

    <bodyclass="bg_white">

   <divalign="center">

   <formaction="set.jsp? staffId=<%=staffId%>"method="post">

              离职原因<br/>

  <textarearows="4"cols="20"id="dimission_reson"name="dimission_reson"></textarea>

   <br/>

   <inputtype="submit"title="提交"id="disreson">

</form>

</div>

  </body>

</html>



原创粉丝点击