Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

javascript - 如果输入a或b是正确/正确,如何执行动作? [重复](How can I execute an action if either input a or b is correct/true? [duplicate])

A user writes 'football' into my input bar and then the action on line 6 and 7 executes.(用户将“足球”写入我的输入栏中,然后执行第6行和第7行的操作。)


But I what if the user writes "Football", with a capital letter?(但是,如果用户用大写字母写“足球”怎??么办?) I tried to implement the "logial or" ||(我试图实现“逻辑或” ||) but I couldn't get it to work.(但我无法正常工作。) var input = document.getElementById("user_input"); let footballTeams = ["Manchester","Barcelona","Copenhagen"] if (input.value == "football") { alert("These cities have football teams:" + " " + footballTeams[0] + "," + " " + footballTeams[1] + "," + " " + footballTeams[2])   ask by Julius Nicolet Nielsson translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

尝试这个:

if (input.value.toLowerCase() == "football")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...