不常用,每次忘记都要查,麻烦,稍微整理了下
html select ajax 前要清空:
$("#id").empty();
下拉框事件 onchange; 方法可获取val 做一定操作;
<select name="proid" id="proid" οnchange="changegetinfo(this.value)"> </select>
html radio 求选中值,当id作为其他用途,不能使用时;
$("#id").empty();
$('input:radio[name="uname"]:checked').val();
同理:
选中单选按钮后的事件也可以这么写
$('body').on('click','[name="uname"]',function(){
var thi = $(this);
getselectpros(thi.val());
});
选中
$('#id“).attr("checked","true");
$("#id").empty();
$("#next_objectid").change(function(){
// var objectid = $(this).data('objectid');
var $this = $(this);
console.log($this);
// var objectid = $(this).attr('data-objectid');拿不到值
var objectid = $(this).find('option:selected').attr('data-objectid'); //取option的值
console.log(objectid);
var data_id1 = $(this).val();
var url = document.location.href;
if(objectid == 0){//全部
url = url.replace("oid",'data_id1');
$("#next_objectid").attr('href',url);
}else{
//替换object_id 的value
}
});
// var objectid = $(this).data('objectid');
var $this = $(this);
console.log($this);
// var objectid = $(this).attr('data-objectid');拿不到值
var objectid = $(this).find('option:selected').attr('data-objectid'); //取option的值
console.log(objectid);
var data_id1 = $(this).val();
var url = document.location.href;
if(objectid == 0){//全部
url = url.replace("oid",'data_id1');
$("#next_objectid").attr('href',url);
}else{
//替换object_id 的value
}
});