jQuery blur event with ID and value

橙三吉。 提交于 2019-12-25 04:06:58

问题


I want to use the 'blur' event in the jQuery text plugin. http://jqueryte.com

$ ('textarea'). jqte ({
blur: function (elem) {
// ID textarea?
// Content editor?
}
});

The function of the blur, I would like to determine the content and the ID of the textarea.

Can you help me with an idea?


回答1:


Since it doesn't look like the blur event is passing any arguments to the callback you might have to do something like

$("textarea").each(function(idx, elem) {
  $(this).jqte({
    blur: function() {
      console.log('blur', this, arguments);
      console.log(elem.id);
      $('#log').append('<div>' + elem.id + '</div>')
    }
  });
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-te/1.4.0/jquery-te.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-te/1.4.0/jquery-te.js"></script>

<div id="log"></div>
<textarea id="t1"></textarea>
<br />
<textarea id="t2"></textarea>
<br />
<textarea id="t3"></textarea>
<br />


来源:https://stackoverflow.com/questions/28082631/jquery-blur-event-with-id-and-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!