为什么$(文件).ready(function(){$(&#34; body&#34;)。prepend(&#39; <p> I \&#39; ma段落!</p>&#39 );});

时间:2018-03-02 01:46:30

标签: jquery

为什么这只适用于&#34; body&#34;?我尝试使用head和id标签但是一旦我将它更改为它就无法工作。即便如此,它仅适用于空白的html,但不适用于此文件。

适合发布quota.text的文本,以适应发布quota.text以适合发布quota.text以适应发布quota.text以适应发布quota.text以适应发布配额。

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script src="jquery.js"></script>
    <script src="myScript.js"></script>

    <style>
    body{font-size:30px;
    font-family: "Arial", "sans-serif";}

    table {
        margin-top:50px;
        background-color:white;
        border: 1px solid black;
        margin-left:auto; 
        margin-right:auto;
        width:50%
    }

    td {
        width: 700px;
        padding: 5px;
        border: 1px solid black;
    }

    .spanrows1,
    .spanrows2 {
         text-align: center;
    }  

    .spanrows1 {
        width: 400px;
    }

    .spanrows2 {
        width: 600px;
    }

    .span2rows {
        text-align: left;
    }

    .squareDivs {
        width:100px;
        height:100px;
        background-color:#000000;
        margin: 10px;
        border-radius: 10px;
        display: inline-block;
    }

    .squareTxt {
        line-height: 100px;
        vertical-align: middle;    
    }

    .alignTxt{text-align: center;}

    </style>
    </head>

    <body> 

        <div class="alignTxt"><span id="titleTxt"></span></div>

    <table>
    <tr>
         <td class='spanrows2'>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
            <div class='squareDivs'><span class='squareTxt'></span></div>
        </td>
    </tr>
    </table>

    </body>
    </html>

1 个答案:

答案 0 :(得分:0)

因为头标记只包含标记

<title> 
<style>
<base>
<link>
<meta>
<script>
<noscript>

如果你附加其他标签,它会被添加到正文