I want to make a function like when inner text is more than the div size then inner text moving left to right autometically infinite.
what I have tried
// chart movement
var chartMove = $(".chart_movement").width();
var chartMovetext = $(".chart_movement")[0].scrollWidth;
if (chartMovetext > chartMove) {
function chart_title_move() {
$(".chart_movement_text")
.animate({
left: "-40px",
right: "40px",
},
5000
)
.delay(1200);
$(".chart_movement_text")
.animate({
left: "40px",
right: "-40px",
},
5000,
function() {
chart_title_move();
}
)
.delay(1200);
}
chart_title_move();
}
.innerTextMove {
overflow: scroll;
position: absolute;
letter-spacing: 0.5px;
position: absolute;
width: auto;
margin: 0 auto;
left: 0;
right: 0;
top: 6px;
}
.chartTitleGuide {
width: 185px;
position: absolute;
white-space: nowrap;
overflow: hidden;
left: 0;
right: 0;
margin: 0 auto;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-start-3 col-span-3 grid justify-center items-center chartTitleGuide"><span class="chart_movement_text">name</span></div>
<div class="col-start-6 col-end-8 grid justify-center items-center chartTitleGuide"> <span class="chart_movement_text">Name</span></div>
problem is var chartMovetext = $(".chart_movement")[0].scrollWidth;
returm 0 everytime .
hope I get some info on how to achieve it.