以下是个人心得整理,有兴趣朋友可以参考参考
$(this).attr(key); 获取节点属性名为key的值,相当于getAttribute(key)方法
$(this).attr(key,value); 设置节点属性名为key的值,相当于setAttribute(key,value)方法
示例:
“radio” name= “orgType” id= “dept”>
var dept = $(“#dept”).attr(“id”); //获得属性名为id的值:dept
是否通过ISO9000标准质量体系认证
ISO9000标准质量体系认证号
知识点:
$(“#id”).prop(“checked”)或$(“#id”).is(“:checked”) 值为false/true;
$(“#id”).attr(“checked”,true) 默认打勾;
if(!$(“.radioCheck”).prop(“checked”)){
$(“#is9000”).hide();
}else{
$(“#is9000”).show();
如下radio打勾,就显示”ISO9000标准质量体系认证号”输入栏,否则就隐藏:
$(“.radioCheck”).bind(“change”,function(){
if($(“.radioCheck”).is(“:checked”)){ //选中
$(“#is9000”).show();
}else{
$(“#is9000”).hide();
}
})
Original: https://www.cnblogs.com/weijun5461/p/16356335.html
Author: 4asd9
Title: Jquery $(this).attr和$(this).val用法示例
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/571808/
转载文章受原作者版权保护。转载请注明原作者出处!