Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Get the max value from array - divi modules

const mainBlog = document.querySelector('.main_blg')
      if (mainBlog != null || mainBlog != undefined) {
        let titleHeights = []
        let contentHeights = []
        const root = document.querySelector(':root');
        const articles = mainBlog.querySelectorAll('article')

        if (articles.length > 0) {
          articles.forEach(article => {
            const title = article.querySelector('.entry-title')
            const content = article.querySelector('.post-content-inner')
            titleHeights.push(title.clientHeight)
            contentHeights.push(content.clientHeight)
          })

          const maxTitle = titleHeights.reduce((a, b) => {
            return Math.max(a, b)
          });
          const maxContent = contentHeights.reduce((a, b) => {
            return Math.max(a, b)
          });

          root.style.setProperty('--title-height', `${maxTitle}px`);
          root.style.setProperty('--content-height', `${maxContent}px`);
        }
      }
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to compile javascript class to function 
Javascript :: jquery keypress div color change 
Javascript :: javascript dom functions 
Javascript :: nodejs mysql set query timeout 
Javascript :: how to convert numbers to roman numerals in javascript 
Javascript :: how to access property from inside an array 
Javascript :: Reversing the elements in an array-like object 
Javascript :: plumsail on change event value 
Javascript :: if the params of usequery updated 
Javascript :: node js knex sqlite query 
Javascript :: Multiple Locale Support momentjs 
Javascript :: check if content is overflowing react 
Javascript :: javascript Vue Component Loading Before Vuex Data Is Set 
Javascript :: angularjs GetVideos API, Cant get the key parameter inside the array 
Javascript :: angularjs Both ng-model and ng-change on input alter the $scope state - which one takes priority 
Javascript :: Fire "data-ng-change" programatically or another way to change value of input on website using Angular JS 
Javascript :: Chrome DevTools - why does variable display in Watch but not under Scope 
Javascript :: Changing Component File location in React native does not show in main App 
Javascript :: adding text to ant media stream 
Javascript :: access language in request express 
Javascript :: string split into three non empty combination js 
Javascript :: make field un updatable mongoose 
Javascript :: json query rails c 
Javascript :: Turn Module Into Non Module 
Javascript :: Class Which Can Create An Instance Of The Same Type 
Javascript :: how to chaage background color of any element from java script 
Javascript :: javascript how to random set rgb colors 
Javascript :: NodeJS Database initialisation 
Javascript :: Toggle image onclicking parent 
Javascript :: function titleCase 2 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =