码迷,mamicode.com
首页 > Web开发 > 详细

jQuery操作控件

时间:2014-06-17 20:26:04      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   color   os   

  在项目中添加前台控件radio,操作两个div的显示和隐藏,其实是一个很简单的问题,但是费了老大劲才完成,也就是jQuery操作控件的一些基础知识。方法有三种,简单介绍:

  

  1、给元素设置style属性: 

$("#divShareExamPage").attr("style", "display:none;");
$("#divExamPage").attr("style", "display:block;");

 

  2、通过jQuery更改控件css样式: 

$("#divShareExamPage").css("display", "none");
$("#divExamPage").css("display", "block");

 

  3、通过jQuery自身的show()、hide()方法: 

$("#divExamPage").show();
$("#divShareExamPage").hide();

 

  

  操作前台控件radio:

<td align ="right">
                            <input type="radio" id="radioTeacherCreate" value ="个人试卷" name ="examPage" checked ="checked" onclick ="clickRadio()"  />个人试卷
                            <input type="radio" id="radioShare" value ="共享试卷" name ="examPage" onclick ="clickRadio()" />共享试卷
                            <input type="radio" id="radioSystem" value ="系统试卷" name ="examPage" onclick ="clickRadio()" />系统试卷
</td>

   提取radio中的value值: 

var radioValue = $("input[name=‘examPage‘]:checked").val();

 

jQuery操作控件,布布扣,bubuko.com

jQuery操作控件

标签:style   class   blog   code   color   os   

原文地址:http://www.cnblogs.com/ysyn/p/3792175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!