Create custom dynamically change horizontal tab function using while loop in javaScript | example how to dynamically change the tabs using Javascript function in Javascript/JQuery

1,150 views


Hey guys, today in this post we are going to learn about How to Create custom dynamically change horizontal tab function using while loop in javascript.

An example of how to dynamically change the tabs using JavaScript function in JavaScript

Final Output →

dynamic horizontal tab while loop in javascript -- w3web.net

 

You can download file directly from github by Click Here.

 

Note:: โ€“ You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
   

Other related post that would you like to learn in Salesforce

 

  • Find the below steps for this post.

Custom dynamically change horizontal tab in JavaScript

Step 1:- Create HTML : tab-menuWhileLoop_w3web.html

horizontal tab function using while loop in javascript [horizontal tab]

  1.   <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Create custom tabs using JavaScript, CSS </title>
  5.  
  6. <style type="text/css">
  7. body{ font-size: 14px; font-family: arial;}
  8. .tabMenu{font-size: 17px; color: #333; margin-bottom: 15px; }
  9. .tabMenu a{text-decoration: none; color: #fff; background-image: linear-gradient(180deg, #bb2200, #b9b900); border-right: 1px #ccc solid; padding: 5px 10px; min-width:100px; text-align:center; display:inline-block;}
  10. .tabMenu a:hover{text-decoration: none; color: #ffff00;}  
  11. .tabMenu a.active{text-decoration: none; background-image: linear-gradient(#00726e, #fff); color: #fff;}  
  12. .tabList{display: none;}
  13. .tabBg{border:1px #ddd solid; background:#eee; padding: 0 0 10px 0; width:70%; background-image: linear-gradient(#fff, #ebebeb);}
  14. .tabContent{display:block; padding:15px; font-size:14px; overflow: hidden;}
  15. .tabContent .postImage{display: inline-block; float: left; margin-right: 20px;}
  16. .tabContent .postImage img{border:1px #ddd solid;}
  17. .readMore{font-size:14px; font-weight:bold; display:inline-block; padding:0 0 0 10px;}
  18. .readMore a{color:#ff0000; text-decoration:none;}
  19. .readMore a:hover{color:#04a5ca; text-decoration:underline;}
  20. .titleTag{font-size:18px;}
  21. .titleTag a{color:#003333; font-weight:bold;}
  22. .imgRt{width:55%; float:left;}
  23. </style>
  24. </head>
  25. <body>
  26.  
  27.  
  28. <script type="text/javascript">
  29.  
  30. function tabFun(a,b){        
  31.    var i=1;
  32.    while(document.getElementById('a' + i)){           
  33.         document.getElementById('a' + i).style.display='none';
  34.         document.getElementById('v' + i).className='';            
  35.         i++;
  36.    }
  37.  
  38.    document.getElementById(a).style.display='block';
  39.    document.getElementById(b).className='active';      
  40.  
  41. }
  42.  
  43. </script>
  44.  
  45. <div class="tabBg">  
  46. <div class="tabMenu" id="tabMenu">
  47. <a href="javascript:void(0)" id="v1" class="active" onClick="tabFun('a1','v1')">Salesforce LWC</a> 
  48. <a href="javascript:void(0)" id="v2" onClick="tabFun('a2','v2')">Tutorial W3web</a> 
  49. <a href="javascript:void(0)" id="v3" onClick="tabFun('a3','v3')">Technical Guide C</a>
  50. </div>
  51.  
  52. <div id="a1" class="tabList" style="display:block;">
  53. <div class="tabContent">
  54.                 <div class="postImage">					
  55.                     <a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">
  56.                         <img src="https://www.w3web.net/wp-content/uploads/2020/12/lwcIfElseConditionFeature.jpg" width="200" height="150"/>
  57.                     </a>
  58.                 </div> 
  59.               <div class="imgRt"> 
  60.                 <h3 class="slds-text-heading_medium slds-text-color--error"><strong>Trigger W3web</strong></h3> 
  61.                 <p class="titleTag"><b><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">Use template if:true and template if:false condition in LWC.</a></b></p>
  62.                 <p>Use template if:true and template if:false condition to display content in LWC</p>                     
  63.                 <p>Today in this post we are going to learn about How do you use template if:true and template if:false condition to display content in lightning web component โ€“ LWC.<span class="readMore"><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer"> more &#8594;</a></span></p>
  64.               </div>    
  65.             </div>
  66. </div>
  67. <div id="a2" class="tabList">
  68. <div class="tabContent">
  69.                 <div class="postImage">					
  70.                     <a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer">
  71.                         <img src="https://www.w3web.net/wp-content/uploads/2020/08/rightSideBanner.png" width="200" height="150"/>
  72.                     </a>
  73.                 </div> 
  74.               <div class="imgRt"> 
  75.                 <h3 class="slds-text-heading_medium slds-text-color--error"><strong>Trigger W3web</strong></h3> 
  76.                 <p class="titleTag"><b><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer">Salesforce Tutorial Easy to Learn Step-by-Step.</a></b></p><br/>
  77.                 <p>Learn step-by-step about Blog, WordPress, Salesforce Lightning Component, Lightning Web Component (LWC)</p><br/>                      
  78.                 <p>w3web.net is the place where you can learn step-by-step about Blog, WordPress, Salesforce Lightning Component, Lightning Web Component (LWC), Visualforce, Technical of Computer Application, Salesforce Plugin, JavaScript, Jquery, CSS, Computer & Accessories, Software Configuration, Customization, Development and much.<span class="readMore"><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer"> more &#8594;</a></span></p>
  79.               </div>    
  80.             </div>
  81. </div>
  82. <div id="a3" class="tabList">
  83.  <div class="tabContent">
  84.                 <div class="postImage">					
  85.                     <a href="https://www.w3web.net/lightning-component-library-developer-guide/" target="_blank" rel="noopener noreferrer">
  86.                         <img src="https://www.w3web.net/wp-content/uploads/2020/12/componentLibraryFeature2.jpg" width="200" height="150"/>
  87.                     </a>
  88.                 </div> 
  89.               <div class="imgRt"> 
  90.                 <h3 class="slds-text-heading_medium slds-text-color--error"><strong>Technical Guide</strong></h3> 
  91.                 <p class="titleTag"><b><a href="https://www.w3web.net/lightning-component-library-developer-guide/" target="_blank" rel="noopener noreferrer">Collection of Lightning Component Library.</a></b></p><br/>
  92.                 <p>A Collection of Lightning Component Library, Developer Guide and Lightning Design System (SLDS)</p><br/>                      
  93.                 <p>ind step-by-step aura documentation component example, Lightning Component Library, Developer guide and Lightning design system. Aura Component:- Input Aura Component:- Date/Time Input Aura Component.<span class="readMore"><a href="https://www.w3web.net/lightning-component-library-developer-guide/" target="_blank" rel="noopener noreferrer"> more &#8594;</a></span></p>
  94.               </div>    
  95.             </div>
  96. </div>
  97. <br/>
  98. <br/>
  99.    <!--Start RelatedTopics Section-->
  100. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  101.  
  102.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click  <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
  103.  
  104.             <br/><br/>
  105.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like โ†’</span> </strong></p>
  106.             <div style="display:block; overflow:hidden;"> 
  107.                 <div style="width: 50%; float:left; display:inline-block">
  108.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  109.                         <li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
  110.                         <li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
  111.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
  112.                         <li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
  113.                         <li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
  114.                     </ul>
  115.             </div>
  116.  
  117.             <div style="width: 50%; float:left; display:inline-block">
  118.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  119.                         <li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
  120.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
  121.                         <li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
  122.                         <li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
  123.                         <li><a href="https://www.w3web.net/update-parent-object-from-child/" target="_blank" rel="noopener noreferrer">update parent field from child using apex trigger</a></li>
  124.                     </ul>
  125.                 </div>
  126.                <div style="clear:both;"></div> 
  127.                <br/>
  128.                 <div class="youtubeIcon">
  129.                     <a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
  130.                 </div>
  131.     </div>
  132.  
  133. </div>
  134.  
  135.   <!--End RelatedTopics Section-->
  136. </div>
  137.  
  138. </body>
  139.  
  140. </html>

 

Further post that would you like to learn in Salesforce

 

How to create a Customize selected tab styles in JavaScript -- w3web.net

 

 

FAQ (Frequently Asked Questions)

How do I make a horizontal tab in HTML?

In HTML the horizontal tab is coded using or &tab; but as with all whitespace characters in HTML

What is vertical tab in JavaScript?

Vertical Tabs are very useful to present the various content easily.

How do you add a horizontal space in HTML?

To create extra spaces before, after, or in-between your text, use the (non-breaking space) extended HTML character.

How do you make a horizontal space?

For example, if you want to insert just one extra blank horizontal line between two paragraphs, you'd just type one once. But if you wanted to add three line breaks, you could type it three times:

Related Topics | You May Also Like

 
Note:: โ€“ You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

Our Free Courses โ†’

๐Ÿ‘‰ Get Free Course โ†’

๐Ÿ“Œ Salesforce Administrators

๐Ÿ“Œ Salesforce Lightning Flow Builder

๐Ÿ“Œ Salesforce Record Trigger Flow Builder

๐Ÿ‘‰ Get Free Course โ†’

๐Ÿ“Œ Aura Lightning Framework

๐Ÿ“Œ Lightning Web Component (LWC)

๐Ÿ“Œ Rest APIs Integration



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment