How to build a customizable custom selected tabs styles using simple JavaScript, CSS with Count (Index) value on click tab button | How to create a customisable selected tab styles in JavaScript

902 views


Hey guys, today in this post we are going to learn about How to build a customizable custom selected tabs styles using simple JavaScript, CSS with Count (Index) value on click tab button select.

Files we used in this post example

customTabs.html HTML File It is used for Create a Custom Tab in JavaScript

customTabsScript.js

JavaScript File It is holding JavaScript click functioality for Show/Hide of the Custom Tab Selected Section.

customTabsStyle.css

Style CSS File It is used for Custom Tab Alignment and Selected Tab Color Style.

Final Output

custom select tabs 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

 

Step 1:- Create HTML File : customTabs.html

customTabs.html [HTML File]

  1.   <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>How to create a Customize selected tab styles in JavaScript</title>
  5. <script type="text/javascript" src="include/customTabsScript.js"></script>
  6. <link rel="stylesheet" href="include/customTabsStyle.css" type="text/css" media="all">
  7. </head>
  8. <body>
  9.  
  10.  <div class="tabMenu" id="tabMenu">
  11.   <a href="javascript:void(0)" rel="tab0" class="active" onClick="tabFun(this)">w3web</a> 
  12.   <a href="javascript:void(0)" rel="tab1" onClick="tabFun(this)">Blog</a> 
  13.   <a href="javascript:void(0)" rel="tab2" onClick="tabFun(this)">Tutorial</a>
  14.   <a href="javascript:void(0)" rel="tab3" onClick="tabFun(this)">Technical Guide</a>
  15.   <a href="javascript:void(0)" rel="tab4" onClick="tabFun(this)">w3web Mart</a>
  16. </div>
  17.  
  18. <div id="tabMainSec">
  19.    <div id="tab0" class="tabList" style="display:block;"> <span class="tabImg"><img src="https://www.w3web.net/wp-content/uploads/2020/08/aboutus.png"  align="top"/></span> w3web.net is the place where you can learn about Blog, WordPress, Salesforce Lightning Component, Lightning Web Component (LWC), Visualforce, Technical of Computer Application, Salesforce Plugin, JavaScript, Jquery, CSS, Computer and Accessories, Software Development, Configuration, Customization and much more... <span class="readMore"><a href="#">Read more...</a></span></div>
  20.  
  21.    <div id="tab1" class="tabList"><span class="tabImg"> <img src="https://www.w3web.net/wp-content/uploads/2020/08/googleNotSearchYourPage.png" align="top"/></span> <p>It is so important to every website should be index by google. Because without indexing our website does not visible on search engine. If google search does not indexing my page. There are β€˜0%’ to chance to get organic traffic. We won’t get any type of organic traffic on search results. </p>
  22.  
  23. <p>Google search engine does not index your site automatically. However if you want to index your website and visible on search results you need to understand about process of Indexing, Crawling and Ranking. <span class="readMore"><a href="#">Read more...</a></span></p>
  24. </div>
  25.  
  26.    <div id="tab2" class="tabList"><span class="tabImg"> <img src="https://www.w3web.net/wp-content/uploads/2020/09/avoidDuplicateWithApex.png" align="top"/></span> Hey guys, today in this post we are going to learn about How to Avoid Duplicate Name Record Simply Using a Apex Controller Method and Validating a Lightning Input Form with Email Regex Pattern Checked and Submit on Click Button in Salesforce Lightning. <span class="readMore"><a href="#">Read more...</a></span></div>
  27.  
  28.     <div id="tab3" class="tabList"><span class="tabImg"> <img src="https://www.w3web.net/wp-content/uploads/2020/07/remote-app2-1-1.png"  align="top"/></span> Many people writing a Blog or Article. There can be multiple pages in a single article, if you have not good hand typing speed you will be face so many difficulty.<br/><br/>
  29.  
  30. If you want to write a article English or Hindi very fast than go through the β€œRemote Mouse App”. <span class="readMore"><a href="#">Read more...</a></span>
  31.  
  32. </div>
  33.  
  34.      <div id="tab4" class="tabList"><span class="tabImg"> <img src="https://www.w3web.net/wp-content/uploads/2020/10/w3webmart_SquareBanner.png"  align="top"/></span> An easy way to online shopping by - www.w3webmart.com such like as Headphone with Mic, Kids Clothing Store, Mens Clothing Store,Mobile Phone, Womens Clothing Store. <span class="readMore"><a href="#">Read more...</a></span></div>
  35.  
  36. </div>
  37.  
  38. <script type="text/javascript">
  39.  </script>
  40.  
  41.  
  42.  <br/>
  43.    <!--Start RelatedTopics Section-->
  44. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  45.  
  46.             <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>
  47.  
  48.             <br/><br/>
  49.             <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>
  50.             <div style="display:block; overflow:hidden;"> 
  51.                 <div style="width: 50%; float:left; display:inline-block">
  52.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  53.                         <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>
  54.                         <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>
  55.                         <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>
  56.                         <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>
  57.                         <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>
  58.                     </ul>
  59.             </div>
  60.  
  61.             <div style="width: 50%; float:left; display:inline-block">
  62.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  63.                         <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>
  64.                         <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>
  65.                         <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>
  66.                         <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>
  67.                         <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>
  68.                     </ul>
  69.                 </div>
  70.                <div style="clear:both;"></div> 
  71.                <br/>
  72.                 <div class="youtubeIcon">
  73.                     <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>
  74.                 </div>
  75.     </div>
  76.  
  77. </div>
  78.  
  79.   <!--End RelatedTopics Section-->
  80. </body>
  81. </html>

Step 2:- Create JavaScript File : customTabsScript.js

customTabsScript.js [JavaScript File]

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  1.    function tabFun(thisEl){   
  2.      var getRel = thisEl.rel;
  3.      var showRelTab = document.getElementById(getRel).style;
  4.      var tabMainList = document.getElementById('tabMainSec').querySelectorAll('.tabList');
  5.      var tabLinkItem = document.getElementById('tabMenu').querySelectorAll('a');
  6.      //alert(tabMainList);
  7.  
  8.      for(i=0; i<tabMainList.length; i++){      
  9.       tabMainList[i].style.display='none';
  10.       tabLinkItem[i].className='';
  11.      }
  12.  
  13.      showRelTab.display='block';
  14.      thisEl.className='active';
  15.    }

Step 3:- Create Style CSS : customTabsStyle.css

customTabsStyle.css [Style CSS File]

  1.   body{ font-size: 14px; font-family: arial;}
  2. .tabMenu{font-size: 13px; color: #333; margin-bottom: 15px; border-bottom:1px #ccc solid;}
  3. .tabMenu a{text-decoration: none; color: #333;  padding: 5px 10px; display:inline-block; border:1px #ccc solid; border-bottom:0; border-radius:5px 5px 0 0;}
  4. .tabMenu a:hover{text-decoration: none; color: #fff; background:#990000; }  
  5. .tabMenu a.active{text-decoration: none; color: #fff; background:#990000; position:relative; padding: 6px 10px 5px 10px; bottom:-1px; }  
  6. .tabList{display: none;}
  7. .tabImg{width:150px; float:left; display:inline-block; margin-right:10px;}
  8. .tabImg img{width:150px; height:100px;}
  9. .readMore{font-size:14px; font-weight:bold; display:inline-block; padding:0 0 0 10px;}
  10. .readMore a{color:#ff0000; text-decoration:none;}
  11. .readMore a:hover{color:#04a5ca; text-decoration:underline;}

 

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)

What is a tab in JavaScript?

JavaScript tabs partition your Web page content into tabbed sections. Only one section at a time is visible. The code is written in such a way that the page degrades gracefully in browsers that don't support JavaScript or CSS.

How do I create a tab in JavaScript?

Create buttons to open specific tab content. All
'div' elements with class='tabcontent' are hidden by default (with CSS & JS). When the user clicks on a button - it will open the tab content that 'matches' this button.

Should I use tabs or spaces?

This highly debated topic has divided programmers for years, but recent data shows that people on the side of using spaces may be right. Recently, the team at Google analyzed a billion files to figure out which technique was better. Their research found that spaces were far better for a number of different reasons.

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