-3

I added two buttons plus and minus; the plus works but minus doesn't work

$("#qqq").click(function () {
    var newValueMinus3 = parseInt($("#text2").val()) - 1;
    if (newValueMinus3 < 0) return;
    $('.lil').css("padding-left", newValueMinus3 +'px');
    // Div
});
2
  • Negative values are not allowed in case of css padding Oct 9, 2014 at 16:48
  • "doesn't work" in what sense? You aren't giving enough info to reproduce or even properly understand the problem.
    – Sam Hanley
    Oct 9, 2014 at 17:11

1 Answer 1

1

A couple of ideas:

  1. Check for isNaN on your ParseInt before doing a math function.
  2. It looks like you're referencing an ID for your click event (#qqq). Your buttons need to have different id's, or else it will only wire up the first one. Use a class (.qqq with an attribute .qqq[operator='plus']), or different id's for each button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.