Extra parentheses in the syntax for a Panel
Hi, I'm currently making my way through a jQuery text book and unfamiliar with some of the code. Specifically, I'm seeking to understand why $panel is assigned $($link.attr('href')) instead of just $link.attr('href'). What is the $()for? Also, when I log the value in the Firefox Console, it holds the value as div#tab-1.tab-panel.active when I only expected #tab-1.
Thanks.
- HTML:
- <ul class="tab-list">
- <li class="active"><a class="tab-control" href="#tab-1"><h3>Desc</h3></a></li>
- ..... etc
- </ul>
- <div class="tab-panel active" id="tab-1"><p> content</p></div>
- ..... etc
-
- JS:
- $('.tab-list').each(function(){ // Finds list of tabs
- var $this = $(this), // gets <ul> list from HTML
- $tab = $this.find('li.active'), // gets active list item
- $link = $tab.find('a'), // gets link from active tab
- $panel = $($link.attr('href'));
- ....