我有2个选择标签。第二是取决于第一个。如果我只检查值,它会工作,但我还需要检查是否已选中。
if(el.val() === "LOCATIONS" || el.is(' option:selected') ){
$("#status option").remove();
$("#status").append("<option value=''>All Packages</option><option value=''>KL</option>");
}
我正在尝试依赖选择下拉列表。如果我删除el.is('option:selected')
,它会根据所选的第一选择选项附加选项。但如果在第一个下拉列表中选择了任何选项,它也应附加选项
这里是jsfiddle
答案 0 :(得分:1)
即使您检查import pygame, os, sys
from pygame.locals import*
pygame.init()
sHEIGHT = 600
sWIDTH = 800
gName = "Survive"
fps = pygame.time.Clock()
FPS = 10
GD = pygame.display.set_mode((sWIDTH,sHEIGHT))
class Main:
white = (255,255,255)
def display(white):
pygame.display.set_caption(gName)
GD.fill(white)
def player1():
img ="Images/"
health = 100
global movex
global movexchange
global movey
global moveychange
global imgplayer1
movex = 400
movey = 400
movexchange = 0
moveychange = 0
imgplayer1 = pygame.image.load(os.path.join(img, "Human.png"))
pygame.display.update()
def gameLoop():
fps.tick(FPS)
while True:
print(fps)
global movexchange
global moveychange
global movex
global movey
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_a:
moveychange = 0
movexchange -=5
if event.key == pygame.K_w:
moveychange -=5
movexchange =0
if event.key == pygame.K_s:
moveychange += 5
movexchange = 0
if event.key == pygame.K_d:
moveychange = 0
movexchange +=5
if event.type == pygame.KEYUP:
if event.key == pygame.K_a:
movexchange =0
moveychange =0
if event.key == pygame.K_w:
movexchange =0
moveychange =0
if event.key == pygame.K_s:
movexchange =0
moveychange =0
if event.key == pygame.K_d:
movexchange =0
moveychange =0
movex += movexchange
movey += moveychange
GD.blit(imgplayer1,(movex,movey))
pygame.display.update()
display(white)
player1()
gameLoop()
即所选选项的值,它也能正常工作。但要传递两个条件,您必须使用one condition
而不是&& operator
,您可以将其更改为el.is('option:selected')
,如下所示,
("el:selected");
&#13;
$(document).ready(function() {
var a = $("#source > option:selected").val();
if(a == "REGIONAL"){
$("#status option").remove();
$("#status").append("<option value=''>All Packages</option><option value='Airports'>Airports</option>");
}
$("#source").change(function() {
var el = $(this);
if((el.val() === "AUDIENCES SEGMENT") && ('el:selected')) {
$("#status option").remove();
$("#status").append("<option value=''>All Packages</option><option value='Youth'>Youth</option><option value='Working Adults'>Working Adults</option><option value='Family'>Family</option><option value='Travellers'>Travellers</option>");
}
else if((el.val() === "REGIONAL") && ('el:selected')) {
$("#status option").remove();
$("#status").append("<option value=''>All Packages</option><option value='Airports'>Airports</option>");
}
else if((el.val() === "LOCATIONS") && ('el:selected')) {
$("#status option").remove();
$("#status").append("<option value=''>All Packages</option><option value=''>KL</option>");
}
});
});
&#13;