我还是jQuery的新手,我遇到了一个小问题.为什么.click函数不会像这样工作:
var $rowStartDate = $("span[id^=rowStartDate]");
var $rowEndDate = $("span[id^=rowEndDate]");
$($rowStartDate, $rowEndDate).click(function() {
//Notice the variables in this selector
Run Code Online (Sandbox Code Playgroud)
但是,当我从变量中移出元素时,它可以工作:
$("span[id^=rowStartDate], span[id^=rowEndDate]").click(function() {
Run Code Online (Sandbox Code Playgroud)