我有一个装有图像的画布.
现在,我想在图像的某些部分标记线条.
所以,我写了一些代码,它们在鼠标拖动上绘制了一条线.
function drawLine(x, y) {
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(x, y);
ctx.closePath();
ctx.stroke();
ctx.restore();
}
canvas.onmousedown = function (e) {
ctx.save();
e.preventDefault();
e.stopPropagation();
startX = parseInt(e.clientX - offsetX);
startY = parseInt(e.clientY - offsetY);
isDown = true;
}
canvas.onmousemove = function (e) {
if (!isDown) {
return;
}
e.preventDefault();
e.stopPropagation();
mouseX = parseInt(e.clientX - offsetX);
mouseY = parseInt(e.clientY - offsetY);
drawLine(mouseX, mouseY);
}
canvas.onmouseup = function (e) {
if (!isDown) {
return;
}
e.preventDefault();
e.stopPropagation();
isDown = false;
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是,拖动创建了一系列而不是一行. …
我有以下 HTML:
单选按钮列表:
<input name="rdLst163" class="required_Mandatory_RbtLst" id="rdLst163_1" onclick="fn("1631");" type="radio" value="1"/>
<input name="rdLst163" class="required_Mandatory_RbtLst" id="rdLst163_2" onclick="fn("1632");" type="radio" value="2"/>
<input name="rdLst163" class="required_Mandatory_RbtLst" id="rdLst163_3" onclick="fn("1633");" type="radio" value="3"/>
<input name="rdLst164" class="required_Mandatory_RbtLst" id="rdLst164_1" onclick="fn("1641");" type="radio" value="1"/>
<input name="rdLst164" class="required_Mandatory_RbtLst" id="rdLst164_2" onclick="fn("1642");" type="radio" value="2"/>
<input name="rdLst164" class="required_Mandatory_RbtLst" id="rdLst164_3" onclick="fn("1643");" type="radio" value="3"/>
Run Code Online (Sandbox Code Playgroud)
复选框列表:
<input name="chLst165" class="required_Mandatory_ChkLst" id="chkLst165_1" onclick="fn("25");" type="checkbox" value="1"/>
<input name="chLst165" class="required_Mandatory_ChkLst" id="chkLst165_2" onclick="fn("25");" type="checkbox" value="2"/>
<input name="chLst165" class="required_Mandatory_ChkLst" id="chkLst165_3" onclick="fn("25");" type="checkbox" value="3"/>
<input name="chLst166" class="required_Mandatory_ChkLst" id="chkLst166_1" onclick="fn("25");" type="checkbox" value="1"/>
<input name="chLst166" class="required_Mandatory_ChkLst" id="chkLst166_2" onclick="fn("25");" type="checkbox" …Run Code Online (Sandbox Code Playgroud)