我收到了一個腳本,叫做jQuery DOM Line,我想用。它允許我通過插入我的變量來在div之間畫一條線。作者告訴我這樣使用它:如何在jQuery函數中使用選項var?
$.line(fromPoint, toPoint[, options]);
其中一個選項叫做className
,我想用一個額外.blue
類添加到.jquery-line
,所以一切的一切所創建的DIV的樣子<div class="jquery-line blue">
。
默認選項是這樣的:
$.line.defaults = {
className: 'jquery-line',
lineWidth: 1,
lineColor: '#000',
returnValues: false
};
我畫我的路線是這樣的:
var firstDot = $(this);
var secondDot = dots.eq(currentIndex + 1 + offset);
firstDot.y = firstDot.offset().top;
firstDot.x = firstDot.offset().left;
secondDot.y = secondDot.offset().top;
secondDot.x = secondDot.offset().left;
$.line(firstDot, secondDot);
我如何添加額外的className?我嘗試過的一些事情,如:
$.line(firstDot, secondDot, [className: 'blue']);
不工作。由於我不習慣他正在使用的語法,有人可以幫我嗎?我知道它必須是東西容易...