如何使用jQuery打开一个新的HTML页面? [英] How to open a new HTML page using jQuery?
问题描述
file1.html
的主文件,然后创建了另一个名为 file2.html的html文件
。 我试图打开file2,但目前为止没有运气。我尝试了以下几段代码:
$ b
-
$(this).load(file2.html );
-
$(div1)。load(file2.html); // div1是file1外部div的id
-
WL.App.openUrl(file2 .html);
-
window.openURL(file2.html);
这些都不起作用!有什么建议吗?
如果你想使用jQuery,.load()函数是你正在使用的正确函数;
但您在示例2中的div1 id选择器中缺少#
这应该是有效的:
$(#div1)。load(file2.html );
So, I am using IBM Worklight where I have the main file called file1.html
and then I created another html file called file2.html
.
I am trying to open file2 but no luck so far. I tried following pieces of code:
$(this).load("file2.html");
$("div1").load("file2.html"); //div1 is the id for outer div of file1
WL.App.openUrl("file2.html");
window.openURL("file2.html");
And none of these worked! Any suggestions?
If you want to use jQuery, the .load() function is the correct function you are after;
But you are missing the #
from the div1 id selector in the example 2)
This should work:
$("#div1").load("file2.html");
这篇关于如何使用jQuery打开一个新的HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!