I am facing an issue with a function that is supposed to draw a line based on its parameters. The problem arises when I make multiple calls to this function. The first function call yields the expected output, however, subsequent calls do not display the line from the first function call. Instead, only the line from the latest function call is shown. Any suggestions on how to resolve this?
function draw_vertical_line(width, height, linecolor, xpos, ypos) {
$('.line').css({
'width': width,
'height': height,
'background-color': linecolor,
'left': xpos,
'bottom': ypos,
'position': 'absolute'
});
}
draw_vertical_line(10, 500, '#357d35', 50, 100); //This line does not show
draw_vertical_line(10, 300, '#357d35', 300, 200); //This line shows
<div class="line"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>