1

我正在使用 Bootstrap wysiwyg5 编辑器作为表单的一部分。

此文本区域恰好是必填字段(不应为空)。我想验证用户是否在此字段上输入了任何值。我看到 Bootstrap wysiwyg 使用 iframe 来显示内容。我尝试通过执行以下操作在 jQuery 中访问 iframe 正文的内容:

$('.textarea.wysihtml5-editor').html()

但失败了。

我的问题是:如何检查用户是否在此 Bootstrap 所见即所得文本区域中输入了一些文本。请帮帮我。

4

2 回答 2

2

你试过这个问题吗?

如何使用 jQuery 访问 iframe 的内容?

上面提到的问题的答案:

$("#myiframe").contents().find("#myContent")

编辑添加我的原始答案:

$('.textarea.wysihtml5-editor').val()
于 2013-06-06T14:21:23.157 回答
1

所见即所得编辑器在引导模式中不起作用,因为它在创建模式之前触发.. 或其他东西。所以最好的方法是在所见即所得编辑器之前触发模态。

function showmymodal(){
$('#modal').modal('show');
$("#modal").html(' <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">modal header</h3></div>
<div class="modal-body">
<textarea id="textarea"></textarea>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</form>');
$('#textarea').wysihtml5({
"font-styles": true, 
"emphasis": true,
"lists": true, 
"html": false, 
"link": true, 
"image": true, 
"color": true 
});
}

你可以在 教程网站上查看

于 2013-07-08T16:07:20.210 回答