看板 Mesak
作者 標題 [JS] Radio Shift Multi Select
時間 2012年11月29日 Thu. PM 05:15:55
http://mesak.tw/?p=624
[JS] Radio Shift Multi Select | Mesak Blog
最近工作需要寫了個小程式,這邊做個紀錄 程式碼在這邊: … Continue reading → ...
最近工作需要寫了個小程式,這邊做個紀錄 程式碼在這邊: … Continue reading → ...
var index = 0;
var shift_down = false;
var radio_group = {
'y':$(':radio[id^="idradio_y"]'),
'n':$(':radio[id^="idradio_n"]')
}
radio_group.y.prop('checked',true);
$(':radio').bind('change',function(){
var this_index = radio_group[this.value].index(this);
if( shift_down )
{
var start = Math.min(index,this_index);
var end = Math.max(index,this_index);
radio_group[this.value].slice(start,end).prop('checked',true);
}
index = this_index
})
$(document).bind('keydown',function(e){
if(e.which == 16 ){
shift_down = true;
$('#output tr').eq(index).addClass('info')
}
}).bind('keyup',function(e){
if(e.which == 16 ){
shift_down = false;
$('#output tr').removeClass('info')
}
}).bind('selectstart',function(){return false})
var shift_down = false;
var radio_group = {
'y':$(':radio[id^="idradio_y"]'),
'n':$(':radio[id^="idradio_n"]')
}
radio_group.y.prop('checked',true);
$(':radio').bind('change',function(){
var this_index = radio_group[this.value].index(this);
if( shift_down )
{
var start = Math.min(index,this_index);
var end = Math.max(index,this_index);
radio_group[this.value].slice(start,end).prop('checked',true);
}
index = this_index
})
$(document).bind('keydown',function(e){
if(e.which == 16 ){
shift_down = true;
$('#output tr').eq(index).addClass('info')
}
}).bind('keyup',function(e){
if(e.which == 16 ){
shift_down = false;
$('#output tr').removeClass('info')
}
}).bind('selectstart',function(){return false})
--
※ 作者: mesak 時間: 2012-11-29 17:15:55
※ 編輯: mesak 時間: 2015-01-28 14:07:49
※ 看板: Mesak 文章推薦值: 0 目前人氣: 0 累積人氣: 148
回列表(←)
分享