Here is the Fiddle: http://jsfiddle.net/3UzsU/
I'm having trouble getting jQuery to recognise the fact that I have changed the data attributes over to get and utilise the new values.
I am detecting the click like so:
$('[data-section="welcome"]').click(function() {
$(this).html('Clicked');
$(this).attr('data-section','expertise')
$(this).attr('data-spaces','2')
});
Once that happens as you can see it changes the data-section and data-spaces, I am then detecting the new click like this:
$('[data-section="expertise"]').click(function() {
$(this).html('Click me');
$(this).attr('data-section','welcome')
$(this).attr('data-spaces','1')
});
I also have this which tells me what is happening:
$('.someClass').click(function() {
var spaces = $(this).data('spaces');
var section = $(this).data('section');
console.log('This number of spaces is: ' + spaces + ' and the section is: ' + section);
});
When I first click, the attributes in the inspector change and when I click again nothing happens. The output is always:
This number of spaces is: 1 and the section is: welcome
Can someone help me in getting the click event to register the new values and run whatever is in that function?