0

I have this code

$(".area").on("keyup", function(){ this.style.height = "1px"; var buttons_matrix = (25 + this.scrollHeight) + "px"; var p = $( "#butons_matrix" ).css('top', buttons_matrix); }); 

How can I make it as soon as the class area is used once don't repeat it again the height, I can't use id here

13
  • 6
    Use .one() instead of .on() Commented Sep 13, 2018 at 8:18
  • As per @Mohammad's comment: api.jquery.com/one Commented Sep 13, 2018 at 8:19
  • You can use off() function of jQuery inside of the handler. e.g. $(".area").off("keyup") or $(this).off("keyup") when you need to disable only the element, not all classes. Commented Sep 13, 2018 at 8:24
  • .one() does not work Commented Sep 13, 2018 at 8:29
  • @lilo Check console for any error also write alert() in .one() to detecting your code is correct. Commented Sep 13, 2018 at 8:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.