繁体   English   中英

如何获取wysihtml5的内部html

[英]How do I get the inner html of a wysihtml5

我有两个wysihtml5字段显示在页面上。 我希望能够使用来自class="vLargeTextField wysihtml5-editor"文本class="vLargeTextField"更新textarea class="vLargeTextField" ,反之亦然。 如果我更新id="user_input" class="vLargeTextField wysihtml5-editor"id="user_input" class="vLargeTextField"应该针对适当的输入进行更新。

我尝试按照以下方式做一些事情:

Userinput1 = $(".wysihtml5-sandbox").contents().find("body").html()

如果我在屏幕上只有一个编辑器,则效果很好。 它返回user_input ,但是如果我更新user_input2 ,则代码类似。 另外,如果我更新user_inputuser_input2 ,我想使用user_input 1或2的输入来更新相应的class="vLargeTextField wysihtml5-editor"

任何帮助,将不胜感激。 请参见下面的代码。

<div name="newboxes" id="user_input" class="text">
    <div style="display:inline-block">
<textarea class="vLargeTextField" cols="80" id="user_input" name="results" rows="20" style="width: 640px; height: 200px; margin: 0px auto; display: none;"></textarea>    
    <iframe class="wysihtml5-sandbox" security="restricted" allowtransparency="true" frameborder="0" width="0" height="0" marginwidth="0" marginheight="0" style="background-color: rgb(255, 255, 255); border-collapse: separate; border: 0.9090908765792847px solid rgb(204, 204, 204); clear: none; display: inline-block; float: none; margin: 0px auto; outline: rgb(85, 85, 85) none 0px; outline-offset: 0px; padding: 3.9914772510528564px 5.994318008422852px; position: static; top: auto; left: auto; right: auto; bottom: auto; z-index: auto; vertical-align: middle; text-align: start; box-sizing: content-box; -webkit-box-shadow: rgba(0, 0, 0, 0.0745098) 0px 0.9090908765792847px 0.9090908765792847px 0px inset; box-shadow: rgba(0, 0, 0, 0.0745098) 0px 0.9090908765792847px 0.9090908765792847px 0px inset; border-top-right-radius: 3.9914772510528564px; border-bottom-right-radius: 3.9914772510528564px; border-bottom-left-radius: 3.9914772510528564px; border-top-left-radius: 3.9914772510528564px; width: 640px; height: 200px;"></iframe>

    #document
        <html>
        <body marginwidth="0" marginheight="0" contenteditable="true" class="vLargeTextField wysihtml5-editor" spellcheck="true" style="background-color: rgb(255, 255, 255); color: rgb(85, 85, 85); cursor: auto; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; line-height: 20px; letter-spacing: normal; text-align: start; text-decoration: none; text-indent: 0px; text-rendering: auto; word-break: normal; word-wrap: break-word; word-spacing: 0px;">
        "Some Text Here"
        </body>
        </html>
    </div>
</div>

<div name="newboxes" id="user_input2" class="text">
    <div style="display:inline-block">
    <textarea class="vLargeTextField" cols="80" id="user_input2" name="results" rows="20" style="width: 640px; height: 200px; margin: 0px auto; display: none;"></textarea>
    <iframe class="wysihtml5-sandbox" security="restricted" allowtransparency="true" frameborder="0" width="0" height="0" marginwidth="0" marginheight="0" style="background-color: rgb(255, 255, 255); border-collapse: separate; border: 0.9090908765792847px solid rgb(204, 204, 204); clear: none; display: inline-block; float: none; margin: 0px auto; outline: rgb(85, 85, 85) none 0px; outline-offset: 0px; padding: 3.9914772510528564px 5.994318008422852px; position: static; top: auto; left: auto; right: auto; bottom: auto; z-index: auto; vertical-align: middle; text-align: start; box-sizing: content-box; -webkit-box-shadow: rgba(0, 0, 0, 0.0745098) 0px 0.9090908765792847px 0.9090908765792847px 0px inset; box-shadow: rgba(0, 0, 0, 0.0745098) 0px 0.9090908765792847px 0.9090908765792847px 0px inset; border-top-right-radius: 3.9914772510528564px; border-bottom-right-radius: 3.9914772510528564px; border-bottom-left-radius: 3.9914772510528564px; border-top-left-radius: 3.9914772510528564px; width: 640px; height: 200px;"></iframe>

    #document
        <html>
        <body marginwidth="0" marginheight="0" contenteditable="true" class="vLargeTextField wysihtml5-editor" spellcheck="true" style="background-color: rgb(255, 255, 255); color: rgb(85, 85, 85); cursor: auto; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; line-height: 20px; letter-spacing: normal; text-align: start; text-decoration: none; text-indent: 0px; text-rendering: auto; word-break: normal; word-wrap: break-word; word-spacing: 0px;">
        "Some Text Here"
        </body>
        </html>
    </div>
</div>

您的问题回答了我的问题。 在您的情况下,我只是将一个ID添加到jQuery选择器中

Userinput = $("#user_input .wysihtml5-sandbox").contents().find("body").html()
Userinput1 = $("#user_input1 .wysihtml5-sandbox").contents().find("body").html()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM