通过jquery将html加载到div中会禁用该div上的脚本

时间:2016-05-07 15:42:42

标签: javascript jquery html

我可以通过jquery成功地将html加载到div中,但是当我无法将脚本应用于该div时。我搜索了整个堆栈溢出,谷歌,尝试了各种各样的事情,如加载脚本等。

    <!doctype html>
    <html lang=''>
    <head>
       <meta charset='utf-8'>  
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <meta name="viewport" content="width=device-width, initial-scale=1">
       <link rel="stylesheet" href="styles.css">
        <link rel="stylesheet" href="sidebarai_nustat.css"> 
       <title>Pasauliniai karai</title>
        <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){     // Loading here
                 $("#cssmenu").load("meniu.html");
                 $(".sidebar1").load("sidebar1.html");
                 $(".sidebar2").load("sidebar2.html");           
            });
        </script>
       </head>

    <body>

      <div class = "visa_puslapio_info ">
        <div id="cssmenu"></div>

        <div class = "main">

            <div class ="sidebar1"> </div>  
            <div class ="sidebar2"> </div>          

            <div class = "turinys" >    
             <p id = 'index_greeting_font'> <img src = "a" id = "index_greeting_nuotrauka" ></img>       
             Sveiki atvykę į pasaulinių karų puslapį!
            </p>
            </div>
        </div>  
        </div>
          <script src="js/sidebar_scriptai/sidebar_script_normal_page.js"></script> // Script doesnt load
        </body>
    <html>

我尝试应用脚本

的sidebar1.html示例
   <!doctype html>
<html lang=''>

<head>

   <meta charset='utf-8'> 
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <title>Pasauliniai karai</title>

   </head>

<body>

        <p id = "raud_spalva" >
        <div id = "div_atsitikt_skaic">
        <font id = "raud_spalva"> Atsitiktinis skaičius: </font>
        <p id ="rand_faktas_skaicius"> </p>
        <p id = "rand_faktas_skaicius_aprasymas"></p> 
        </div>
        </p>

        <p id = "sidebar_nauja_rubrika"><br><font id ="raud_spalva">  </font> <br> <br>
                <iframe src="" width="180" height="180" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
        </p>
</body>
<html>

0 个答案:

没有答案