title: How to close currently open tab on click in Chrome extensions?
body: <p>Found the answer. It should be:</p>
  
  <pre><code>var currTab = tabs[0].id;
  </code></pre>
  
  <p>Original question:</p>
  
  <p>I've recently started to learn about javascript and chrome extensions. I am trying to make it so that whenever the extension icon is clicked, it simply closes whichever tab is currently selected. </p>
  
  <p>My code for my background.js file:</p>
  
  <pre><code>chrome.browserAction.onClicked.addListener(function(tab) {
  
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
      var currTab = tabs[0];
      chrome.tabs.remove(currTab);
    });
  });
  </code></pre>
  
  <p>And the manifest.json file </p>
  
  <pre><code>{
    "manifest_version": 2,
  
    "name": "None",
    "description": "N/A",
    "version": "1.0",
  
    "browser_action": {
      "default_title": "Click to Close"
    },
    "permissions": [
      "tabs"
    ]
  }
  </code></pre>
  
  <p>So far, clicking the extension icon does absolutely nothing.</p>