Вопрос по javascript – Событие onclick не запускается, когда onchange срабатывает непосредственно перед

3

Error: User Rate Limit Exceeded

У меня есть текстовая область, с которой связано событие onchange. Тогда у меня есть кнопка, связанная с событием onclick.

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

I typed in a text into the textarea. Right after typing i click on the button to trigger the onclick event on the button Nothing happens, but the onchange event on the textarea got triggered when i clicked on the button, but the onclick event on the button itself doesnt get triggered.

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

<textarea onchange="processText();" name="mytext"></textarea>
<button onclick="processButton();">Hello</button>
<script language="Javascript">
  function processText()
  {
    alert( 'textarea');
  }

  function processButton()
  {
    alert( 'button');
  }
</script>
Error: User Rate Limit Exceeded Gavriel
Error: User Rate Limit Exceeded NovumCoder
Error: User Rate Limit Exceeded JJJ
Error: User Rate Limit Exceeded coolguy

Ваш Ответ

3   ответа
4

Error: User Rate Limit Exceededalert()Error: User Rate Limit ExceededonclickError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededonchangeError: User Rate Limit ExceededonclickError: User Rate Limit Exceeded

<textarea onchange="processText();" name="mytext"></textarea>
<button onclick="processButton();">Hello</button>
<div id="clicked"></div>
<div id="changed"></div>
<script language="Javascript">
  function processText()
  {
    document.getElementById('changed').innerHTML = "onchange fired";;
  }

  function processButton()
  {
    document.getElementById('clicked').innerHTML = "onclick fired";
  }
</script>​

Error: User Rate Limit ExceededonclickError: User Rate Limit ExceededonchangeError: User Rate Limit ExceededmouseupError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
0

document.getElementsByTagName("textarea")[0].addEventListener("change", function(){
    alert( 'textarea');
});

document.getElementsByTagName("button")[0].addEventListener("click", function(){
    alert( 'button');
});

IdsgetElementById().

1

Error: User Rate Limit Exceeded NovumCoder

Похожие вопросы