简体   繁体   中英

Cannot focus on button when focused in textarea in mobile

I have a textarea which when a user types some text into and clicks the button underneath, the button will not work the first time, you have to push twice on the button to make it work. It's as if the first time you click it you are focusing out of the textarea (the keyboard closes) and the second time is to click the button. This only happens in mobile (galaxy s3 and iphone4).

Anyone know what I can do to stop it from doing that?

This is my js code

jQuery('.nextButton').click(function () {
  alert('clicked');
});

HTML

<div class="questionOptions selectionTextarea">
       <textarea rows="4" cols="40" name="s3q1" id="textareas3q1"></textarea>
       <input type="button" value="Next" class="nextButton">
</div>

try to add return false;

jQuery('.nextButton').click(function () {
  alert('clicked');
  return false;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM