具有ID和值的jQuery模糊事件 [英] jQuery blur event with ID and value

查看:107
本文介绍了具有ID和值的jQuery模糊事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在jQuery文本插件中使用'blur'事件. http://jqueryte.com

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

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

模糊的功能,我想确定文本区域的内容和ID.

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

你能帮我个主意吗?

推荐答案

由于看起来blur事件未将任何参数传递给回调,因此您可能必须执行类似的操作

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 />

这篇关于具有ID和值的jQuery模糊事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆