Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Add marquee dynamically

I am trying to add a marquee to my HTML dynamically. This is the function I have created

                var element = document.getElementById('overflow');
                var parentElement = document.getElementById('countheader');
                if (element) {
                    var overflow = isElementOverflowing(element, parentElement);
                    if (overflow && !element.classList.contains('marquee')) {
                        element.className += "marquee";
                    } else if (!overflow) {
                        element.classList.remove('marquee');
                    }
                }

function isElementOverflowing(element, parentElement) {
        return parentElement.clientWidth <= element.clientWidth;
    }

In the CSS file I have the styling as

 #countheader{   
        background-color: #e9df8b;
        width: fit-content;
        white-space: nowrap;
        min-width: 100%;
        overflow: hidden;
        padding-left: 11px!important;
        max-width: 1266px!important;
    }
    #overflow{
        max-width: 1266px!important;
    }

#HTML

 <div class="page-content" style="background-color: {{isDarkMode ? '#000000' : '#FFFFFF'}}">

                    <!-- Item Count Card-->

                    <div class="order-card item-card"
                         ng-if="currentStation.get('enableItemCount') && viewTitle === 'Open Orders' && currentStation.get('itemCountFilters').length > 0 && itemsCount.length > 0">
                       
                        <div class="card-header"  id="countheader">
                                <div id="overflow">
                                    <b class="item-heading">Total Count</b>
                                    <span  class="item-count" ng-repeat="item in itemsCount">{{item.name}}({{item.quantity}})</span>
                                </div>
                        </div> 
                    </div>
                    <!-- Item Count Card -->

But in some cases, I am seeing that the text overflows the parent div in the UI but in the function isOverflowing it is still showing parent element width greater and so the marquee does not gets added in the class. Is there a better way to find the height of the parent div and child div content?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!