—Original code—-
$(function () {
var options = {
xaxis: { mode: "time", tickLength: 5 },
selection: { mode: "x" },
crosshair: { mode: "x" }
};
});
I want crosshair: { mode: “x” } to be inside of options variable when rlt=true.
Following is my code, but it’s not correct.Is there anyone can point error out?
Thanks!
$(function () {
var rlt = true;
var options;
if(rlt){
options = {
xaxis: { mode: "time", tickLength: 5 },
selection: { mode: "x" },
crosshair: { mode: "x" }
};
}else{
options = {
xaxis: { mode: "time", tickLength: 5 },
selection: { mode: "x" }
};
}
});
works for me, but you can write it this way: