jq——监听input组件type=“radio“单选框的change事件——基础积累

应用场景

jq的基操,但是由于本人jq操作dom不熟悉,用vue习惯了,所以还是要记录一下jq的基操,多多积累,多多收获。

jq基础操作——监听input组件的change事件

在这里插入图片描述

1.html代码

<div class="radioChange">
    <label for="type0">
        <input type="radio" name="type" value="0"  id="type0" checked/>整体
    </label>
    <label for="type1">
        <input type="radio" name="type" value="1" id="type1"/>内贸
    </label>
</div>

2.css代码

.radioChange{
    
    
	font-size:20px;
	color:#f90;
	font-weight:bold;
	padding-left:80px;
	margin-bottom:8px;
}
.radioChange input {
    
    
    width:20px;
    height:20px;
    margin-right:8px;
    position:relative;
    top:4px;
}

3.js代码

var type;
$(".radioChange :radio").on("click", function () {
    
    
   console.log($(this).val())
    type = $(this).val();
    //其他方法
})

完成!!!

多多积累,多多收获!!!

猜你喜欢

转载自blog.csdn.net/yehaocheng520/article/details/128832519
今日推荐