试图在jquery .load(" myHTML.html")上触发body'onLoad'事件 [英] Trying to trigger body 'onLoad' event on jquery .load("myHTML.html")

查看:97
本文介绍了试图在jquery .load(" myHTML.html")上触发body'onLoad'事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主要在页面加载时构建的html,当我独立运行它时,它运行得很好,但我需要将这个html放在另一个html的div中,我使用ajax / jquery的.load函数

I have an html which mostly builds itself on page load, it works perfectly when I run it independently , but I need to put this html inside another html's div, I do this using ajax/jquery's .load function

$('#myDiv')。load('myHtml.html')

但是在div中以这种方式加载它不会触发body onload事件并且页面没有正确构建。你能建议我怎么能以某种方式触发body onload函数或其他一些方法来实现相同的

but loading it this way in the div doesn't trigger the body onload event and the page is not properly build. Can you suggest how I can somehow trigger the body onload function or some other way to achieve the same

推荐答案

将它置于 $(document).ready()

   $(document).ready(function(){

        $('#myDiv').load('myHtml.html');
   });

这篇关于试图在jquery .load(" myHTML.html")上触发body'onLoad'事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆