jQuery How do I focus on contents of iframe after clearing

后端 未结 2 1432
执笔经年
执笔经年 2021-01-25 05:09

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

相关标签:
2条回答
  • 2021-01-25 05:32

    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();
    
    0 讨论(0)
  • 2021-01-25 05:33

    I'm not sure I understand what you are trying to do, but postContentClr is a jQuery object, so calling html() requires that you access it via jQuery like so:

    $(postContentClr).html('').focus();
    
    0 讨论(0)
提交回复
热议问题