Reputation: 1103
Simple line of code:
var page=jQuery("#buy-items-button").attr('id');
Problem is that page
is undefined
. Relevant portion of html
<li><a id='#buy-items-button' href="#buy-items" data-page="buy-items" class="section-button">Buy Items</a></li>
console.log(jQuery("#buy-items-button"))
shows:
[context: document, selector: "#buy-items-button", jquery: "1.9.1", constructor: function, init: function…]
context: document
selector: "#buy-items-button"
__proto__: Object[0]
Driving me crazy as having been using jQuery for long and never faced issues on such trivial calls.
Upvotes: 1
Views: 52
Reputation: 16764
Your HTML is wrong (remove # from id attribute):
<a id='#buy-items-button' href="#buy-items"
should be
<a id='buy-items-button' href="#buy-items"
Upvotes: 0
Reputation: 38102
You need to remove #
from id value of your anchor:
<li><a id='buy-items-button' href="#buy-items" data-page="buy-items" class="section-button">Buy Items</a></li>
Upvotes: 4