Is it feasible to animate a JQuery slider?

Is there a way to animate the slider using jQuery? I want to be able to press a button and have the inner part of the slider move slower (e.g. 300ms) without reacting to mouse clicks and slides.

Here is the code: http://jsfiddle.net/gm4tG/5/

HTML:

<div id='slider' class='sliderBar'></div>
<button>Remove 10%</button>

CSS:

html, body {
    height:100%;
    width:100%;
    margin:0;
    padding:0;
}
#slider {
    height:20px;
    max-height:20px;
}
.sliderBar-progress {
    background:rgb(0, 255, 0);

}

JS:

$('#slider').sliderBar({
    start: 100,
    onChange: function (val) {
        var red = 0,
            green = 0;
        if (val >= 50) {
            red = 255 - Math.round(((val - 50) / 50) * 255);
            green = 255;
        } else {
            red = 255;
            green = Math.round(((val) / 50) * 255);

        }
        $('.sliderBar-progress').css({
            background: "rgb(" + red + "," + green + ",0)"
        });
    }
});

$('button').on('click', function () {
 $('#slider').setsliderBar($('#slider').getsliderBar()-10, true);
});

Thank You very much!

Answer №1

.sliderBar-progress {
    background:rgb(0, 255, 0);
    transition-duration: 5s;
    -webkit-transition-duration: 5s; /* for Safari */
}

This particular style works seamlessly across various browsers including Chrome, Firefox, Internet Explorer 10, Opera, and Safari.

Check out the updated version on JSFiddle here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Alert event in JavaScript navigating between different pages

My website features two dynamic php pages: customer invoices and customer management. One common request from my users is the ability to swiftly add a new customer directly from the customer invoices page. Instead of cluttering the customer invoices page ...

In-line divs are known for their rebellious nature, refusing to conform to traditional

I'm in need of some assistance with taming my unruly HTML. It seems to be misbehaving lately. The content area on the page I'm currently designing has a two-column layout. Instead of using separate containing divs for each column, I opted for a ...

Does this function only function on a singular div?

I need some help! I'm having trouble getting a function to trigger on the divs below the initial one. Any advice? ...

Adjust the color of each list item depending on an array of strings

Within my perspective, I possess a collection of different statuses. <ul> <li>FIRST_STATUS</li> <li>SECOND_STATUS</li> <li>THIRD_STATUS</li> </ul> To continuously update the statuses in my contr ...

Struggling to Understand Middleware in Node.js Express

I am currently delving into Express.js and finding myself a bit puzzled by the nuances between middleware functions and route handlers. I grasp the concept that middleware functions typically include the next argument, but I am struggling to discern when a ...

I am encountering an issue with the functionality of my button display and hide feature in my code

I have a button that toggles between my favorite items and I want it to change its appearance when clicked. The button should be updated after a successful ajax call. However, the issue I am facing is that when I click on the hide button, the show button ...

Tips for combining dvloading and required functionalities on the submit button

My form has 2 fields that must be filled out, and I used the required attribute to enforce this rule. Enter A:<input type="text" name="a" required><br> Enter B:<input type="text" name="b" required><br> <button type="submit" cl ...

What is the best way to place two radio buttons side by side in a row?

How can I place two radio buttons in a single row with their labels, like the example shown in the picture? ...

Dividing Faces with Lengthy Edges in three.js into Two Separate Faces

I am currently working on a script that involves splitting overly long edges of faces into two separate faces instead of one large face. The final result is exported to a .obj file. Although the geometry reduction works fine, I have noticed some issues a ...

Implementing a sticky header for tables using Bootstrap

I'm experiencing a conflict because the header remains fixed only when I include the table-responsive class in my code. However, I also need the table to have overflow. Can anyone provide assistance with this issue? Using the table-responsive class ...

Transform the column's datetime into a date in the where condition when using sequelize

Hey there, I'm looking to convert a datetime column into just date format while running a query. Could someone assist me with creating a Sequelize query based on the example below? select * from ev_events where DATE(event_date) <= '2016-10- ...

Using router.get with a redirect in Express

Can you directly invoke a router.get(...) function in Express? Let's say I have a router.get('/my-route', function(req, res) { ... });, is it feasible to then, within another part of my code, use res.redirect('my-route'); with the ...

What is the process for loading this image?

While browsing through this stunning website, I came across a feature that caught my eye. Can someone please explain how the designer displayed the "The magic is loading" effect: The image vanishes once the site has finished loading completely. ...

Challenges in working with PHP, SQL, HTML, and AJAX data submission

Having encountered another issue, I've been attempting to make an AJAX script function properly, but whenever I click on it, the page reloads without updating the database field. The code I'm using has successfully worked for similar scripts on ...

Encountering a null pointer exception when using a post method, JSON, and AJAX

Implementing Server Side Logic @Path("/create") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) public RequestStatus createData(String jsonData){ return ...

Retrieve the value of each element within the elements array

I need help retrieving values from elements within an array. Specifically, I am looking to extract the value of the <span id="attendees"> element within each <a> element. For example: HTML: <a id="meetingItem_{{meeting.id}}" onclick="Auth ...

What is the best way to display the logged-in user's username in the Bootstrap navbar once they

I currently have a login button on my navbar that opens up a login modal. I would like to replace the login button with the username of the logged-in user in that modal. I'm relatively new to PHP and MySQLi, only been here for about a week. I would ...

Animated CSS side panel

I'm currently working on creating an animation for a side menu. The animation works perfectly when I open the menu, but the problem arises when I try to animate it back closed. Is there a property that allows the animation to play in reverse when the ...

Tips for incorporating VueJS 2 global components within single file components

As I attempt to utilize a globally registered component (using Vue.component) within a single file component, I consistently encounter the following warning: vue.common.js:2611[Vue warn]: Unknown custom element: <my-component> - did you register the ...

Retrieve the value of an li element and send it to an AJAX request

I am experiencing an issue with my treeview list where I am trying to send the id of the selected li element via ajax, but for some reason, the code is not functioning as expected. You can view the old code here: http://jsfiddle.net/esS4k/379/ Check out ...