引用嵌套JQuery中的原始html元素
Reference original html elements in nested JQuery
这个简单的问题是我对JQuery理解中的一个缺陷。
$('input').focus(function() {
$('.popup').click(function() {
//How do I reference the original input that
//triggered the focus event here?
});
});
正如你从标题中可以看出的那样,我在寻找答案时遇到了问题。。。
您可以添加这样的引用:
$('input').focus(function() {
var originalInput = $(this);
$('.popup').click(function() {
console.log(originalInput.val());
});
});
$('input').focus(function() {
var orig = $(this);
$('.popup').click(function() {
//How do I reference the original input that
//triggered the focus event here?
console.log(orig);
});
});
相关文章:
- 如何使用JavaScriptLib将字符串(WYSIWYG)转换为原始html
- 获取原始HTML并将其重新呈现为HTML
- Webpack:如何将原始HTML加载为React JSX
- 表情符号显示为原始 HTML 代码
- 正在将DOM元素转换为原始HTML字符串
- 保存对“;contentEditable;部分返回到原始HTML文件
- 当我附加XSS过滤后的html时,它会打印原始html
- Electron:将原始html注入BrowserWindow
- 有没有一种方法可以用javascript将原始html添加为新的表行
- 如何在 MVC 中使用 javascript 作为原始 html 插入内容 ASP.NET
- 按 Esc 按钮后恢复为原始 html
- 确定元素是否由 JS 添加,还是原始 HTML 文档 *OR* 检测脚本何时通过 InnerHTML 更新节点
- 获取聚合物元素的原始 HTML 代码
- DOM、原始 html 以及页面上显示的内容是什么关系
- 原始HTML样式与jQuery生成的具有相同结构的HTML不同
- 使用 jquery 检索原始 html,而不是渲染的 html
- Angularjs:在双花括号内渲染原始html - 可能
- 如何将 html 元素添加到当前文本区域值,并将其输出为原始 html
- Angularjs routing 使用 $state 得到原始 html 标签
- 如何将节点内容从 xml 复制到硬编码的 html(动态到原始 html)