Advertisement
Ranga14

AtAuction.com Product Page JQuery Tab Highlight

Aug 14th, 2013
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     // Product Page Tab Highlight
  3.     $(document).ready(function() {
  4.         $("#TabProductInfo li a").each(function() {
  5.             $(this).click(function() { 
  6.                 // Grab value of id attribute
  7.                 var vID = $(this).attr("id");
  8.                 // Find the id dynamically and find the current bg image of the hover state
  9.                 var hov = $("#" + vID + ":hover").css("background-image");
  10.                 // Set an inline style with the hover state's bg
  11.                 $(this).attr("style", "background-image: " + hov);
  12.                
  13.                 // After selecting a new tab, iterate through prior tabs and remove their bg images
  14.                 $("#TabProductInfo li").find("a").each(function() {
  15.                     sValue = $(this).attr("class");
  16.                     if (sValue != "selected") {
  17.                         $(this).removeAttr("style");
  18.                     }
  19.                 });
  20.             });
  21.         });
  22.     });
  23. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement