Nội dung từ <p> biến mất khi tôi quay lại trang (Content from <p> disappears when I return to the page)


問題描述

Nội dung từ

biến mất khi tôi quay lại trang (Content from

disappears when I return to the page)

I'm facing a strange problem. I use a HTML template and it's actually only one page with a box in the middle. The content of the box can change and you navigate to the different version by some buttons at the top of the page.

I have added a paragraph in the landing view and when I move to another view and return back the text disappears.

I can see that the problem isn't that it doesn't show the  text, the problem is that it completely disappears and only leaves:

<div id="comment2" class="one‑half"></div>

I cannot figure out what causes it though.

Here's my HTML:

<div id="content_wrapper">
    <div id="header"><span>Το <b>INTRO HALL</b> είναι το <b>TOP</b>!</span><div id="close"></div></div>
    <div id="content">
    <div class="scroll‑pane">
        <div class="content" id="content1">
        <div id='subscribe_label'>Η ιστοσελίδα του γυμναστηρίου Intro Hall θα ανοίξει σε:</div>
        <div id="counter"></div><div class="clear"></div>
        <div class="form_title"><h1>Κέρδισε ένα δώρο!</h1></div>
        <div class="column_cont">
        <div id="comment2" class="one‑half"><p>Συμπλήρωσε τη διπλανή φόρμα για να μπεις στο Club Επικοινωνίας του Intro Hall και κέρδισε ένα δώρο. Απλά γράψε το όνομα και το email σου και κλίκαρε 'Στείλτε το δώρο μου!'.</p></div>
            <!‑‑ Begin MailChimp Signup Form ‑‑>
<div id="mc_embed_signup" class="one‑half" style="float:right;">
<form action="http://topgreekgyms.us6.list‑manage2.com/subscribe/post?u=d6acf8949532b107b7b21c9d0&amp;id=e2131451dc" method="post" id="mc‑embedded‑subscribe‑form" name="mc‑embedded‑subscribe‑form" class="validate" target="_blank" novalidate>

<div class="mc‑field‑group">
    <input type="text" value="" name="FNAME" class="required" id="firstname" placeholder="Όνομα">
</div>

<div class="mc‑field‑group" style="margin‑bottom:4px;">
    <input type="email" value="" name="EMAIL" class="required email" id="primaryemail" placeholder="Email" style="float:right;">
</div>

    <div id="mce‑responses" class="clear">
        <div class="response" id="mce‑error‑response" style="display:none"></div>
        <div class="response" id="mce‑success‑response" style="display:none"></div>
    </div>  

    <div class="clear"><input type="submit" value="ΣΤΕΙΛΤΕ ΤΟ ΔΩΡΟ ΜΟΥ!" name="subscribe" id="mc‑embedded‑subscribe" class="button_link hover_fade large_button red"></div>
</form>
</div>

<!‑‑End mc_embed_signup‑‑>
</div>          
</div>

And here's the CSS

#content_wrapper {
        position:absolute;
        width:506px;
        height:506px;
        z‑index: 1000;
        top:0;
        left:0;
        /* Fallback for web browsers that doesn't support RGBa */
        background: rgb(62, 62, 62);
        /* RGBa with 0.6 opacity */
        background: rgba(0, 0, 0, 0.52);
}

#header {
        width:506px;
        height:47px;
        background: #161616;
}

#header span {
    display:block;
    margin:auto;
    height: 100%;
    line‑height: 47px;
    width:447px;
    color: #ffffff;
    padding: 0px 29px 0 29px;
    background: #ac0003;
    text‑align:center;
    font‑family: arial;
    font‑size: 23px;
    text‑transform: none;
    word‑spacing: 5px;
}

#content {
    width: 502px;
    height: 306px;
    border: 2px solid #161616;
    border‑width: 0 2px 0 2px;
    margin‑top:‑15px;
    padding‑top:15px;
}

.content {
        display:none; 
        width: 458px;
}

#close {
    position: absolute;
        top:11px;
        right:12px;
        background: transparent url(../img/close.png) no‑repeat;
        width:25px;
        height: 25px;
        cursor: pointer;
        display:none;
}

.column_cont {
    margin: 0 ‑15px 0 0px;
    clear:both;
}

.clear {clear:both;}

#comment2 {
color: #fff;
display:block;
font‑size: 16px;
text‑align: justify;
line‑height: 20px;
margin‑bottom:10px;
}

.one‑half, .one‑third, .two‑third, .one‑fourth,  .three‑fourth {
    margin:0 5px 0 15px;
    float:left;
}

.one‑half {
    width:206px;

}

Also, here's a link to the website.

Thanks in advance for any help or opinions!


參考解法

方法 1:

In your big_countdown.js file, there is a listener on the close button which contains document.getElementById('comment2').innerHTML = ""; : 

$("#close").click(function() {
        $('.content').each(
            function() {
                $(this).fadeOut('fast');
            });
        $('#content1').stop().fadeIn('fast');
        $("#close").css('display','none');
                $('#dots div').each(
            function() {
                $(this).removeClass('dot_active');
            });
        $("#dot1").addClass('dot_active');
        window.setTimeout(function() {
         api.reinitialise();
        },300);

        // Remove this line below
        document.getElementById("comment2").innerHTML="";
});

Removing this last line should solve the problem.

方法 2:

Using a good JavaScript debugger can help you figure this out really quickly next time. Firebug, an add‑in to Fixfox is one of the best. To get to the same answer as albertxing you can do the following steps:

  1. Load the page 
  2. Right click on the element that is disappearing and select "Inspect element with Firebug"
  3. Your 

     element will be highlighted in Firebug's HTML viewer

  4. Right‑click on on this element and select "break on element removal"
  5. Toggle the buttons at the bottom of your web page to make the 

     element disappear

  6. Firebug will detect the change and take you immediately to the line of code that caused it to change.

Presto!

(by kat_indoAlbert XingMatt Wielbut)

參考文件

  1. Content from

    disappears when I return to the page (CC BY‑SA 3.0/4.0)


#css #html






相關問題

在圖像上淡入文本 (Fade in text over an image)

可以使用 css3 轉換輪廓顏色 (possible to transition outline color with css3)

以背景色為條件的 if 語句 (If statement with background color as condition)

Nội dung từ <p> biến mất khi tôi quay lại trang (Content from <p> disappears when I return to the page)

當按鈕向右浮動時,ng-click 不起作用 (ng-click doesn't work when the button is floated to the right)

帶有偽 css 的背景顏色層 (Background color layer with pseudo css)

是否可以製作離線工作的網絡應用程序? (Is it possible to make a web-app which works offline?)

chrome中帶有省略號的多行文本問題 (issue with multiline text with ellipsis in chrome)

將字符串轉換為類的安全名稱 (Convert string to safe name for class)

絕對定位跨度收縮 (Absolute Positioned Span Shrinks)

如何設置單選按鈕的樣式,使其看起來像普通的可點擊按鈕? (How do I style a radio button to look like a normal clickable button?)

無法獲得白色和灰色的 CSS 進度條 (Not able to get the CSS progress bar with white and grey)







留言討論