0

I have selects with some values, and i want to remember value by clicking one of them and after change do something with this.

 $("select[id^='zmieniaj']").click(function() {
      var poprz=$(this).val();
      $("select[id^='zmieniaj']").change(function(){
      ...
});
});

So im remembering clicked value in variable and i refer to it in change function. It works good when i click only once on select and made change in the same step. If i click few times it does not trigger change function imimmediately, but it remembers how many times i clicked and when i made change it acts crazy by making up for previous clicks.

How to do that, if CONDITION A-click and CONDITION B-change is made only then, and only once do what is in change function ??

1
  • why do you want to use the click handler Commented Feb 7, 2014 at 11:03

1 Answer 1

1

Try something like

$("select[id^='zmieniaj']").focus(function () {
    var $this = $(this);
    $this.data('fvalue', $this.val());
}).change(function () {
    var $this = $(this),
        cval = $this.val(),
        pval = $this.data('fvalue');
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for fast and concrete answer. Works great.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.