我使用过滤,但我有问题,我有 4 个选项输入,其中我有一些数据需要在表中过滤,现在我只过滤一列的数据,但问题是我是否会再添加一个过滤器,脚本将不起作用,并从最后选择的值过滤数据。但是如果我在选项数据中有 2-4 个选定的值,我需要过滤。
我的代码:JS:
$("#cancelFilters").hide();
$('#filterButton').click(function () {
getSelectedVal()
filterData()
filters = [];
$("#cancelFilters").fadeIn();
});
var filters = [];
function getSelectedVal() {
var materialCode = $('#materialCode option:selected').text()
var plantCode = $('#plantCode option:selected').text()
var vsCode = $('#vsCode option:selected').text()
var status = $('#statusCode option:selected').text()
applyFilter(materialCode, 1)
applyFilter(plantCode, 2)
applyFilter(vsCode, 3)
applyFilter(status, 4)
}
function applyFilter(value, id) {
if (value)
filters.push('.column' + id + ':contains(' + value + ')');
}
function filterData() {
if (filters.length > 0) {
var rows = …Run Code Online (Sandbox Code Playgroud) 我想创建倒计时时间,但我找不到这样的信息,我该怎么做。
例如我有200 分钟它是3,3 小时。
对于这3,3 小时我想要倒计时,我可以在标签上看到这些信息吗?
我怎么能做到这一点?
我在论坛上找到了这样的代码:
func startTimer() {
let releaseDateString = "03:33:00"
let releaseDateFormatter = DateFormatter()
releaseDateFormatter.dateFormat = "HH:mm:ss"
releaseDate = releaseDateFormatter.date(from: releaseDateString)! as NSDate
countdownTimer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true)
}
@objc func updateTime() {
let currentDate = Date()
let calendar = Calendar.current
let diffDateComponents = calendar.dateComponents([.hour, .minute, .second], from: currentDate, to: releaseDate! as Date)
let countdown = "Hours \(diffDateComponents.hour ?? 0), Minutes \(diffDateComponents.minute ?? …Run Code Online (Sandbox Code Playgroud) 我有阵列:
let array = ["", "Therapeutic Dentistry","Surgical Dentistry","Orthopedic Dentistry","Orthodontics","Genaral Medical Questions","Children Therapeutic Dentistry","Children Surgical Dentistry"]
Run Code Online (Sandbox Code Playgroud)
我想要第一个,它是空的,我怎么能从数组中获取这个元素?
我遇到问题,更改语言后,我想重新启动应用程序。
所以,我想提醒消息的文字“ 你要重新启动应用程序更改语言吗? ”“ 是 ”“ 否 ”
如果用户按YES,我如何重新启动应用程序?
我的解决方案:
let alertController = UIAlertController(title: "Language".localized(), message: "To changing language you need to restart application, do you want to restart?".localized(), preferredStyle: .alert)
let okAction = UIAlertAction(title: "Yes".localized(), style: UIAlertActionStyle.default) {
UIAlertAction in
NSLog("OK Pressed")
exit(0)
}
let cancelAction = UIAlertAction(title: "Restart later".localized(), style: UIAlertActionStyle.cancel) {
UIAlertAction in
NSLog("Cancel Pressed")
}
alertController.addAction(okAction)
alertController.addAction(cancelAction)
self.present(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
应用关闭后,用户将手动启动应用。