我想我不会这么做,对jquery来说很新.我有一个隐藏着3个食谱的页面.当点击配方A的链接时,它会以模态打开.我希望能够只打印食谱的内容.所以我打开一个新窗口(非模态)并尝试将配方写入其中(取决于选择的配方)
这是我正在使用的代码
$('a.new-window').click(function(){
var recipe = window.open('','RecipeWindow','width=600,height=600');
$('#recipe1').clone().appendTo('#myprintrecipe');
var html = "<html><head><title>Print Your Recipe</title></head><body><div id="myprintrecipe"></div></body></html>";
recipe.document.open();
recipe.document.write(html);
recipe.document.close();
return false;
});
Run Code Online (Sandbox Code Playgroud)
但它返回一个错误.我认为它很接近但不太正确.错误是:缺失; 在声明之前[打破此错误] var html ="Print ... ="myprintrecipe">"; \n
$('.menu div.profile-btn').on('click', function () {
$('.mainservice-page').fadeIn(1200);
}
Run Code Online (Sandbox Code Playgroud)
上面的脚本.mainservice-page成功打开了div的内容,但是我想在新选项卡中打开它们.
我怎样才能做到这一点?
提前致谢.