javascript - jQuery displaying NaN -


i'm trying data element in html, jquery "nan" when ask jquery place grabbed data in paragraph tag.

here full code:

$(".next-panel").click(function(event) {      var accordion = $(".nav-accordion")     var index = accordion.accordion('option','active')     var next = index + 1;     var panel = $(this).parents('.accordion-panel').next();     var sectiontitle = $(this).parents('.accordion-panel').parents('li').next('li').children('a').attr('data-title');     var sectiondesc = $(this).parents('.accordion-panel').parents('li').next('li').children('a').attr('data-desc');     var sectionpercent = $(this).parents('.accordion-panel').parents('li').next('li').children('a').attr('data-percent');      $('body').animate({         scrolltop: $('#accordion-wrap').offset().top     },     800      );      accordion.accordion('activate', next);     panel.removeclass("ui-state-disabled").bind("click");       $('#progress-box h6').text(sectiontitle);     $('#progress-box p').text(sectiondesc);     $('#percent-bar-inner p').text(sectionpercent);     $('#percent-bar-inner').animate({         width: sectionpercent,     }, 300);      console.log(sectionpercent)      event.preventdefault();     return false;   }); 

when use this:

var sectionpercent = $(this).parents('.accordion-panel').parents('li').next('li').children('a').attr('data-percent'); 

and tell output var to:

$('#percent-bar-inner p').text(sectionpercent); 

it gives me:

nan 

but when log variable, gives me:

50 

which correct value.

why happen , nan mean?!


update

js fiddle examples:

this js fiddle showing working expected:

http://jsfiddle.net/87qte/

with these bits of code removed:

var accordion = $(".nav-accordion") var index = accordion.accordion('option','active') var next = index + 1; var panel = $(this).parents('.accordion-panel').next(); 

and also

accordion.accordion('activate', next); panel.removeclass("ui-state-disabled").bind("click"); 


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -