Jquery 从iframe层中的文本框位置获取内容

Jquery 从iframe层中的文本框位置获取内容,jquery,iframe,popup,layer,Jquery,Iframe,Popup,Layer,我是jquery的新手,所以您的帮助/指南对我来说是新的。我有一个文本框,我写html标签。现在我想做的是预览按钮。它应该打开一个jquery层/弹出窗口,其中包含我文本框中的书面html,这样我就可以使用它了。你们有什么方法可以指导我在哪里找到这样的脚本或者帮我一点忙吗?我已经搜索过了,但我找到的只是如何用外部资源打开iFrame。我需要将自己的html传递到iframe中 thx提前您真的需要使用iframe或弹出窗口吗?还有其他类似的解决方案,它们不会强制您使用单独的HTML文档元素。或者

我是jquery的新手,所以您的帮助/指南对我来说是新的。我有一个文本框,我写html标签。现在我想做的是预览按钮。它应该打开一个jquery层/弹出窗口,其中包含我文本框中的书面html,这样我就可以使用它了。你们有什么方法可以指导我在哪里找到这样的脚本或者帮我一点忙吗?我已经搜索过了,但我找到的只是如何用外部资源打开iFrame。我需要将自己的html传递到iframe中


thx提前

您真的需要使用iframe或弹出窗口吗?还有其他类似的解决方案,它们不会强制您使用单独的HTML文档元素。或者,您可以使用任何元素:

$("#target").html($("#source").html())

您真的需要使用iframe或弹出窗口吗?还有其他类似的解决方案,它们不会强制您使用单独的HTML文档元素。或者,您可以使用任何元素:

$("#target").html($("#source").html())

好的,假设您有一个ID为
txtBody
的文本区域,一个ID为
button
的触发器按钮,以及一个ID为
dialog
的空div,将用于对话框。
那么你就必须这样做:

<script type="text/javascript">
    $("#button").click(function() {
        $("#dialog").html($("#txtBody").html());
        $("#dialog").dialog();
    });
</script>

$(“#按钮”)。单击(函数(){
$(“#dialog”).html($(“#txtBody”).html());
$(“#dialog”).dialog();
});

只是别忘了在该页面中包含jQuery和jQuery UI。

好的,假设您有一个ID为
txtBody
的文本区域,一个ID为
的触发器按钮和一个ID为
的空div对话框将用于该对话框。
那么你就必须这样做:

<script type="text/javascript">
    $("#button").click(function() {
        $("#dialog").html($("#txtBody").html());
        $("#dialog").dialog();
    });
</script>

$(“#按钮”)。单击(函数(){
$(“#dialog”).html($(“#txtBody”).html());
$(“#dialog”).dialog();
});
只是别忘了在该页面中包括jQuery和jQuery UI。

这对我很有用:

<link href="jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="ui.core.js" type="text/javascript"></script>
<script src="ui.dialog.js" type="text/javascript"></script>

<input type="submit" value="Submit" id="button" />
<input  type="text" id="txtBody" />
<br />

<div id="dialog" style="display: none;">
</div>

<script type="text/javascript">
    $("#button").click(function() {
        $("#dialog").html($("#txtBody").val());
        $("#dialog").dialog().dialog("open");
    });
</script>


$(“#按钮”)。单击(函数(){ $(“#dialog”).html($(“#txtBody”).val()); $(“#dialog”).dialog().dialog(“打开”); });
实际上,我使用.html()是错误的。正确的方法是使用.val()

<link href="jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="ui.core.js" type="text/javascript"></script>
<script src="ui.dialog.js" type="text/javascript"></script>

<input type="submit" value="Submit" id="button" />
<input  type="text" id="txtBody" />
<br />

<div id="dialog" style="display: none;">
</div>

<script type="text/javascript">
    $("#button").click(function() {
        $("#dialog").html($("#txtBody").val());
        $("#dialog").dialog().dialog("open");
    });
</script>


$(“#按钮”)。单击(函数(){ $(“#dialog”).html($(“#txtBody”).val()); $(“#dialog”).dialog().dialog(“打开”); });

实际上,我使用.html()是错误的。正确的方法是使用.val()。

尽管文本框中输入的是HTML,但我相信需要的是.val()函数,而不是.HTML()。试试看,我可能错了,我知道他想把输入呈现为HTML。当然,我也可能错了。哦,我还假设它是一个,所以.html()可以工作。但是,他说的“textbox”也可能是指一个普通的文本框。虽然输入文本框的是HTML,但我相信需要的是.val()函数,而不是.HTML()。试试看,我可能错了,我知道他想把输入呈现为HTML。当然,我也可能错了。哦,我还假设它是一个,所以.html()可以工作。但他说的“文本框”也可能是指普通人。