Jump to content
MakeWebGames

Jquery Stat Bar Help


k1ngscorp1o

Recommended Posts

Im trying to code a system where there is a minus button a bar showing how full your stat is and then a plus button, on minus the bar goes down and on plus it goes up. I've been looking for different ways to do this all day and the closest I've found is this:

HTML:

<div style="background-color:white; width:10%; height:100%;"></div>

 

I need to access that 10 right before the percent sign and manipulate that number but Im unsure how with any method.

JS:

 

$(function(){

       var valueElement = $('#test');
       function incrementValue(e){
           valueElement.text(Math.max(parseInt(valueElement.text()) + e.data.increment, 0));
           return false;
       }

       $('#stat1_plus').bind('click', {increment: 1}, incrementValue);

       $('#stat1_minus').bind('click', {increment: -1}, incrementValue);

   });

 

I think this would be the functionality im looking for but combining this with a bar Im not sure how to go about doing it. Has anyone done something similar or know an alternative?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...