Open In App

Foundation CSS JavaScript Miscellaneous Utilities

Foundation CSS is a responsive front-end framework for building web applications. It includes a set of CSS styles and JavaScript functions that can be used to create a  responsive layout and add interactivity to a website.

Foundation CSS JavaScript miscellaneous utilities:



Example 1: This code demonstrates how to use the Foundation.GetYoDigits() function.




<!DOCTYPE html>
<html>
<head>
    <title>Foundation GetYoDigits Example</title>
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
</head>
<body>
    <center>
        <h1 style=color:green>GeeksforGeeks</h1>
        <h3> Foundation CSS JavaScript Miscellaneous Utilities</h3>
        <button id="generate-id-button">
            Generate ID
        </button>
        <div id="generated-id"></div>
        <script>
            // Get a reference to the button and generated ID element
            var button = document.getElementById('generate-id-button');
            var generatedID = document.getElementById('generated-id');
  
            button.addEventListener('click', function() {
                // Generate a new ID with the Foundation.GetYoDigits
                var newID = Foundation.GetYoDigits(6, 'my-element-');
                generatedID.textContent = newID;
            });
        </script>
   </center>
</body>
</html>

Output:



 

Example 2: This code demonstrates how to use the Foundation.getFnName() function.




<!DOCTYPE html>
<html>
<head>
  <title>Foundation getFnName Example</title>
  <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
</head>
<body>
    <center>
        <h1 style=color:green>GeeksforGeeks</h1>
        <h3> Foundation CSS JavaScript Miscellaneous Utilities</h3>
        <button id="get-fn-name-button">Get Function Name</button>
        <div id="function-name"></div>
        <script>
            function testFunction() {
                console.log('This is a test function');
            }
            var button = document.getElementById('get-fn-name-button');
            var functionName = document.getElementById('function-name');
              
            button.addEventListener('click', function() {
                // Get the function name with the Foundation.getFnName
                var fnName = Foundation.getFnName(testFunction);
  
                functionName.textContent = fnName;
            });
        </script>
   </center>
</body>
</html>

Output:

 

Example 3:




<!DOCTYPE html>
<html>
<head>
    <title>Foundation transitionend Example</title>
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
</head>
<body>
    <center>
        <h1 style=color:green>GeeksforGeeks</h1>
        <h3> Foundation CSS JavaScript Miscellaneous Utilities</h3>
        <!-- Create a button to trigger the transition -->
        <button id="transition-button">
            Trigger Transition
        </button>
  
        <!-- Create a div to apply the transition to -->
        <div id="transition-div" 
             style="background-color: red; 
                  width: 100px; height: 100px; 
                  transition: width 0.5s ease;">
        </div>
  
        <script>
            var button = document.getElementById('transition-button');
            var transitionDiv = document.getElementById('transition-div');
            button.addEventListener('click', function() {
                // Toggle the width of the 
                // transition div between 100px and 200px
                if (transitionDiv.style.width === '100px') {
                    transitionDiv.style.width = '200px';
                } else {
                    transitionDiv.style.width = '100px';
                }
            });
  
            // Use the Foundation.transitionend function 
            // to listen for the end of the transition
            Foundation.transitionend(transitionDiv, function() {
              console.log('Transition ended');
            });
        </script>
    </center>
</body>
</html>

Output:

 

Reference: https://get.foundation/sites/docs/javascript-utilities.html#miscellaneous


Article Tags :