php - Trouble with referencing a javascript variable using jquery -


i'm trying animate div element changes width.

the problem want change width variable that's stored in .js file , i'm not sure how recognize it.

my html code:

<section style="width:100%;  height:120px;  clear:both;" >     <section class="campaign_statistics" style="background-color:#efefef;">          <?php include('progress_chart.php'); ?>      </section> </section> 

uses include php file contains:

if ($blog_id == 9)     echo     '     <script>     var percent = string(businessprogress.getpercent());     document.write(businessprogress.tostring());     </script>     ' ; 

i defined variable percent referenced in jquery. .js file has object made stores variables , made getters info when needed.

the tostring() method:

this.tostring = function(){     var string = '<div class="campaign_progress" style="width:0%;"> <div class="campaign_percentage_bar">' + string(this.getpercent()) + '% percent unit progress</div> <div class="campaign_dollars">$' + myslice(this.getcurrent()) + '<span class="goal"> of $' + myslice(this.getgoal()) + '</span></div></div>'; return string; } 

basically builds div element want animate.

the width set @ 0% , when jquery called in header:

<script>     $(document).ready(function() {         $(".campaign_percentage_bar").animate({width:string(percent)+'%')}, 5000);     }); </script> 

this how i'm referencing variable. have script calls in header, should ok. if can give suggestions or if need clarify more or give more info, please comment.

try this

$(".campaign_percentage_bar").animate({width:percent+'%'}, 5000); 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -