jQuery清除后如何集中处理iframe的内容 [英] jQuery How do I focus on contents of iframe after clearing

查看:190
本文介绍了jQuery清除后如何集中处理iframe的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个所见即所得的iframe,用户可以在其中将输入提交到页面上的另一个区域.提交iframe输入后,我将其设置为清除内容.我还希望自动将焦点重新放回到iframe中.

I currently have a wysiwyg iframe where the user can submit input to another area on the page. Once the iframe input is submitted, I set it to clear the content. I want to also automatically focus back into the iframe.

这是我目前拥有的代码:

This is the code I currently have:

postContentClr = $("iframe#textarea1IFrame").contents().find("body")
postContentClr.html(" ").focus();

推荐答案

弄清楚了.我只需要专注于父母.而且抖动是正确的,因为我已经将其声明为jQuery对象,所以不需要对其进行包装.

工作代码:

Figured it out. I had to simply focus on the parent. And Jitter is correct, since I already declared it as a jQuery object, it needn't be wrapped.

Working code:

postContentClr = $("iframe#textarea1IFrame").contents().find("body")
postContentClr.html("").parent().focus();

这篇关于jQuery清除后如何集中处理iframe的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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