https://jsfiddle.net/5r60uqtp/2/
如果我点击第一个输入,然后按住shift并点击第三个输入,为什么这不能全部选择3?
def main():
while True:
try:
name = input("Please enter the student's name: ") #Asks for students name
while name == "":
print("This is invalid, please try again")
name = input("Please enter the students name: ")
teacher_name = input("Please enter the teacher's name: ") #Asks for teachers name
while teacher_name == "":
print("This is invalid, please try again")
teacher_name = input("Please enter the teacher's name: ")
marker_name = input("Please enter the marker's name: ") #Asks for markers name
while marker_name == "":
print("This is invalid, please try again")
marker_name = input("Please enter the marker's name: ")
break
except ValueError:
print("This is invalid, please try again")
main()
答案 0 :(得分:1)
我想我得到了你想要达到的目标......
但是由于鼠标事件与键盘事件不同,我可能会有一个想法作为替代。如果您在按住Shift键的同时mouseover
复选框切换其选中状态会怎样?
就像这样:
var shiftHeld = false;
// Turn the shiftHeld flag to true
$(document).on("keydown",function(e){
if(e.shiftKey){
shiftHeld = true;
}
});
// Turn the shiftHeld flag to false
$(document).on("keyup",function(e){
shiftHeld = false;
});
// On mouseover, if shifHeld is true, toggle checked state of the mouseovered checkboxes
$("input[type='checkbox'].grid-item").on("mouseover",function(){
if(shiftHeld){
$(this).prop("checked",!$(this).prop("checked"));
}
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li><input type="checkbox" class="grid-item">One</li>
<li><input type="checkbox" class="grid-item">Two</li>
<li><input type="checkbox" class="grid-item">Three</li>
</ul>
&#13;