gpt4 book ai didi

javascript - jQuery 优化 - 干

转载 作者:行者123 更新时间:2023-11-28 19:22:18 27 4
gpt4 key购买 nike

我的情况很简单:

$("#check-in").dateDropper({
years_multiple: "10",
format: "d-m-Y",
minYear: "2015",
maxYear: "2016",
lang: "pt",
animation: "bounce",
placeholder: "Dia da entrada."
});

$("#check-out").dateDropper({
years_multiple: "10",
format: "d-m-Y",
minYear: "2015",
maxYear: "2016",
lang: "pt",
animation: "bounce",
placeholder: "Dia da saída."
});

唯一的区别是占位符:“...”。

如何优化此代码使其不重复(DRY)?

最佳答案

试试这个:

$("#check-in, #check-out").dateDropper({
years_multiple: "10",
format: "d-m-Y",
minYear: "2015",
maxYear: "2016",
lang: "pt",
animation: "bounce",
placeholder:($(this).attr('id') == "check-in" ? "Dia da entrada." : "Dia da saída.")
});

关于javascript - jQuery 优化 - 干,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28625914/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com