Vote up and down jQuery

Increment and Decrement Operators jquery

Cool vote up and down jQuery
DEMO / DOWNLOAD

<div class="vote-box">
    <input type="text" id="vote" />
    <button id="increaseButton" class="btn up">+</button>
    <button id="decreaseButton" class="btn down">-</button>
</div>
// Set the initial value of the textbox
$("#vote").val('0');

// Create a click handler for your increment button
$("#increaseButton").click(function () {
    var newValue = 1 + parseInt($("#vote").val());
    $("#vote").val(newValue);
});
// .. and your decrement button
$("#decreaseButton").click(function () {
    var newValue = parseInt($("#vote").val()) - 1;
    $("#vote").val(newValue);
});
.vote-box {
    padding: 10px;
    background: #EEE;
    border: 1px dotted #CCC;
    display: inline-block;
    margin-top: 10px;
}
.btn {
    position: relative;
    top: 0;
    left: 0;
    vertical-align: middle;
    padding: 4px 10px;
    line-height: 100%;
    cursor: pointer;
    width: auto;
    overflow: visible;
    font-weight: normal;
    font-size: 23px;
    text-shadow: 0 1px 0 #FFF;
    text-decoration: none;
    vertical-align: middle;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    display: inline-block;
    zoom: 1;
    border: 0px solid #CCC;
    color: #FFF;
}
.up {
    margin-left: -4px;
    background-image: -webkit-gradient(radial, 5% 5%, 0, 5% 5%, 50, color-stop(0%, #62C462), color-stop(100%, #3B9E3B));
    background-image: -webkit-radial-gradient(5% 5%, #62C462 0%, #3B9E3B 50px);
    background-image: -moz-radial-gradient(5% 5%, #62C462 0%, #3B9E3B 50px);
    background-image: -o-radial-gradient(5% 5%, #62C462 0%, #3B9E3B 50px);
    background-image: radial-gradient(5% 5%, #62C462 0%, #3B9E3B 50px);
}
.up:hover {
    background-image: -webkit-gradient(radial, 5% 5%, 0, 5% 5%, 50, color-stop(0%, #528947), color-stop(100%, #34572D));
    background-image: -webkit-radial-gradient(5% 5%, #528947 0%, #34572D 50px);
    background-image: -moz-radial-gradient(5% 5%, #528947 0%, #34572D 50px);
    background-image: -o-radial-gradient(5% 5%, #528947 0%, #34572D 50px);
    background-image: radial-gradient(5% 5%, #528947 0%, #34572D 50px);
}
.down {
    margin-left: -6px;
    background-image: -webkit-gradient(radial, 5% 5%, 0, 5% 5%, 50, color-stop(0%, #EE5F5B), color-stop(100%, #E51D18));
    background-image: -webkit-radial-gradient(5% 5%, #EE5F5B 0%, #E51D18 50px);
    background-image: -moz-radial-gradient(5% 5%, #EE5F5B 0%, #E51D18 50px);
    background-image: -o-radial-gradient(5% 5%, #EE5F5B 0%, #E51D18 50px);
    background-image: radial-gradient(5% 5%, #EE5F5B 0%, #E51D18 50px);
}
.down:hover {
    background-image: -webkit-gradient(radial, 5% 5%, 0, 5% 5%, 50, color-stop(0%, #C33), color-stop(100%, #8F2424));
    background-image: -webkit-radial-gradient(5% 5%, #C33 0%, #8F2424 50px);
    background-image: -moz-radial-gradient(5% 5%, #C33 0%, #8F2424 50px);
    background-image: -o-radial-gradient(5% 5%, #C33 0%, #8F2424 50px);
    background-image: radial-gradient(5% 5%, #C33 0%, #8F2424 50px);
}
input {
    display: inline-block;
    vertical-align: middle;
    width: auto;
    zoom: 1;
    margin: 0;
    border: 1px solid #CCC;
    font-size: 1em;
    padding: 5px 0;
    text-indent: 5px;
    background: #FFF;
    -moz-box-shadow: inset 0px 0px 6px #ccc;
    -webkit-box-shadow: inset 0px 1px 6px #CCC;
    box-shadow: inset 0px 1px 6px #CCC;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}
input[disabled] {
    cursor: not-allowed;
    background-color: #EEE;
}
Vote up and down jQuery Vote up and down jQuery Reviewed by Bhaumik Patel on 7:50 PM Rating: 5