我有:
<body marginwidth="0" marginheight="0" contenteditable="true"
class="bootsy required form-control bootsy_text_area wysihtml5-editor"
spellcheck="true"
style="color: rgb(85, 85, 85); cursor: auto; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; 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; background-color: rgb(255, 255, 255);">
</body>
我使用了以下代码,但是它没有起作用:
if ($("body").hasClass("wysihtml5-editor")) {
$("body").html('this is a test content.');
});
我在我的Rails应用程序中使用Bootsy,它会在浏览器的源代码中生成此body标记。因此,我想首先使用jQuery查找具有类的此body标记,然后设置一些值。请帮帮我。
this
是什么?如果该代码位于事件处理程序中,则this
将是事件的目标,而不是主体。如果您想设置主体内容,为什么不写$("body").html()
呢? - Barmar