1.
<!-- 装港不填 -->
用css来控制样式,因为无法用jquery的来操作input的type属性,用replaceWith替换标签后无法使用fros框架的插件功能,只能使用css的样式来控制input.
<script type="text/javascript">
function bwferLP(){
if(document.getElementById("lushang").checked){
$(".inline").css('display' , 'none');
$(".hidden").css('display' , 'inline');
}else{
$(".inline").css('display' , 'inline');
$(".hidden").css('display' , 'none');
}
}
</script>
2.each以及replaceWith的使用
$("#fendan").each(function(){
$(this).replaceWith('<li id="fendan"><label>分单号:</label><input name="bwfrHblNo" id="bwfrHblNo" controltype="number" style="width: 150px"></li>');
});
3.是否被选中
js实现:document.getElementById("lushang").checked
jquery实现:$("#id").attr("checked");
$("#id").attr("class","true/false");
4.select被选中
$("#id option:selected").text();
radio
Jquery老的版本
var_name = $(“input[@name='radio_name']:checked”).val();
Jquery 1.3以后的版本
var_name = $(“input[name='radio_name']:checked”).val();//选择被选中Radio的Value值
1. $("input[name='radio_name'][checked]").val(); //选择被选中Radio的Value值
2. $("#text_id").focus(function(){//code...}); //事件 当对象text_id获取焦点时触发
3. $("#text_id").blur(function(){//code...}); //事件 当对象text_id失去焦点时触发
4. $("#text_id").select(); //使文本框的Vlaue值成选中状态
5. $("input[name='radio_name'][value='要选中Radio的Value值 '").attr("checked",true); //根据Value值设置Radio为选中状态
CheckBox
1. $("input[name='checkbox_name'][checked]");or$("input[name='checkbox_name']:checked");/选择被选中CheckBox元素的集合 如果你想得到Value值,你需要遍历这个集合
2. $($("input[name='checkbox_name'][checked]")).each(function(){arrChk+=this.value + ',';}); //遍历被选中CheckBox元素的集合 得到Value值
3. $("#checkbox_id").attr("checked"); //获取一个CheckBox的状态(有没有被选中,返回true/false)
4. $("#checkbox_id").attr("checked",true); //设置一个CheckBox的状态为选中(checked=true)
5. $("#checkbox_id").attr("checked",false); //设置一个CheckBox的状态为不选中(checked=false)
6. $("input[name='checkbox_name']").attr("checked",$("#checkbox_id").attr("checked")); //根据3,4,5条,你可以分析分析这句代码的意思
7. $("#text_id").val().split(","); //将Text的Value值以','分隔 返回一个数组
分享到:
相关推荐
6.4.1 replaceWith(content) 103 6.4.2 replaceAll(selector) 104 6.5 删除 104 6.5.1 empty() 104 6.5.2 remove([expr]) 105 6.5.3 detach([expr]) 106 6.6 复制 106 6.6.1 clone() 106 6.6.2 clone(true) 107 7. ...
jQuery详细教程,讲解很透彻, 一. jQuery 语法实例 $(this).hide() 演示 jQuery hide() 函数,隐藏当前的 HTML 元素。 $("#test").hide() 演示 jQuery hide() 函数,隐藏 id="test" 的元素。 $("p").hide() ...
$.jQuery( selector [, context] ), .jQuery( element ), .jQuery( elementArray ), .jQuery( jQueryObject ), .jQuery( ) $.jQuery( html [, ownerDocument] ), .jQuery( html, props ) $.jQuery( fn ) jQuery ...
replaceWith(content) replaceAll(selector) 删除 empty() remove([expr]) 复制 clone() clone(true) 筛选 过滤 eq(index) hasClass(class) filter(expr) filter(fn) is(expr) map(callback) not(expr) ...
replaceWith(content) replaceAll(selector) 删除 empty() remove([expr]) 复制 clone() clone(true) 筛选 过滤 eq(index) hasClass(class) filter(expr) filter(fn) is(expr) map(callback) not(expr) ...
jQuery 1.11.0 速查表 核心 jQuery 核心函数 jQuery([sel,[context]]) jQuery(html,[ownerDoc])1.8* jQuery(callback) jQuery.holdReady(hold) jQuery 对象访问 each(callback) size() length selector ...
jQuery.extend(object) 多库共存 jQuery.noConflict([ex]) 属性属性 attr(name) attr(properties) attr(key, value) attr(key, fn) removeAttr(name) CSS 类 addClass(class | fn) removeClass([class | fn]) ...