treehouse : what would you like to learn today?
Web Design Web Development iOS Development

optgroup (parent/child relationships)

  • i need to makes optgroups in the select based on the parent/child relationships

    when i look my web at smartphone or tablet... i cant see a separation for father menu. (www.benditaflor.cl)

    how can i make this visual variation?

    Actually code in scripts.js is:

            // Create the dropdown base
      jQuery("<select />").appendTo("#main-menu-wrapper");
    
      // Create default option "Go to..."
      jQuery("<option />", {
        "selected": "selected",
        "value"   : "",
        "text"    : goText
      }).appendTo("#main-menu-wrapper select");
    
      // Populate dropdown with menu items
      jQuery("#main-menu a").each(function() {
        var el = jQuery(this);
        jQuery("<option />", {
          "value"   : el.attr("href"),
          "text"    : el.text()
        }).appendTo("#main-menu-wrapper select");
      });
    
      // To make dropdown actually work
      jQuery("#main-menu-wrapper select").change(function() {
        window.location = jQuery(this).find("option:selected").val();
      });