how to write a better jquery ?
please help me simplify this
- $(document).ready(function() {
$('#aContent').cycle({
fx: 'scrollHorz',
prev: '#prev',
next: '#next',
timeout: 0,
after: onAfter1
});
$('#aContent2').cycle({
fx: 'scrollHorz',
prev: '#prev2',
next: '#next2',
timeout: 0,
after: onAfter2
});
$('#aContent3').cycle({
fx: 'scrollHorz',
prev: '#prev3',
next: '#next3',
timeout: 0,
after: onAfter3
});
function onAfter1(curr, next, opts, fwd) {
var index = opts.currSlide;
$('#prev')[index == 0 ? 'hide' : 'show']();
$('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}
function onAfter2(curr, next, opts, fwd) {
var index = opts.currSlide;
$('#prev2')[index == 0 ? 'hide' : 'show']();
$('#next2')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}
function onAfter3(curr, next, opts, fwd) {
var index = opts.currSlide;
$('#prev3')[index == 0 ? 'hide' : 'show']();
$('#next3')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}
}
how to simplify this code ?
let me learn with this case, please help