簡體   English   中英

如何在部門內部關閉部門

[英]how to close division inside division

可能是我無法在一個行標題中描述我的問題。描述如下。

我提示使用除法..頁面上的html是..

<button id="prompt_open" name="prompt_open">open</button>
<div id="prompt" style="display:none"></div>

現在,我通過javascript(jquery)代碼在提示中生成和html的屬性。

$("#post_video").click(function () {
        var the_prompt = $("#Stuffprompt_main");
        the_prompt.css('display', 'block');
        var prompt_html = "";
        the_prompt.css('top', '95px');
        the_prompt.css('position', 'absolute');
        the_prompt.css('left', '300px');
        the_prompt.css('width', '610px');
        the_prompt.css('border', 'thin');
        the_prompt.css('background-color', '#FFF');
        the_prompt.css('height', 'auto');
        the_prompt.css('z-index', '9999');
        the_prompt.attr('id', 'post_prompt');
        the_prompt.attr('name', 'post_prompt');

        var shut_box = "<a id=\"close_prompt_vdo\" name=\"close_prompt_vdo\" class=\"shut\"></a>";

        var header = '<div class="header_prompt"><span id="pr" class="prompt_title">Post video of your stuff</span></div>';
        var middler = "<form action=\"user_posting/post_video.php\" name=\"posting_photos\" id=\"posting_photos\" method=\"post\" enctype=\"multipart/form-data\">" +
            "<div class=\"object_container\">" +
            "<textarea name=\"title_postvideo\" id=\"title_postvideo\" class=\"descriptor\" maxlength=\"100\" placeholder=\"Tilte\" style=\"height:30px;\" ></textarea>" +
            "<textarea name=\"text_postvideo\" id=\"text_postvideo\" class=\"descriptor\" maxlength=\"200\" placeholder=\"Add some description\" ></textarea>" +
            "<div class=\"file_Container\">" +
            "<div class=\"text_box_container\">" +
            "<textarea name=\"YTB_link\" id=\"YTB_link\"  class=\"descriptor\" style=\"float:left;width:75%; border:thin; border-color: #333;\"  maxlength=\"200\" placeholder=\"Add link of your video on You tube\"></textarea>" + "<div style=\"float:left; width:120px; height:80px; background-repeat:no-repeat; background-image:url(images/tube_logo.jpg);\"></div></div>" + "<div class=\"gap\"></div>" + "<div class=\"text_box_container\">" + "<textarea name=\"VMO_link\" id=\"VMO_link\" class=\"descriptor\" style=\"float:left;width:75%; border:thin; border-color: #333;\"  maxlength=\"200\" placeholder=\"Add link of your video on Vimeo\"></textarea>" + "<div style=\"float:left; width:135px; height:80px; background-repeat:no-repeat; background-image:url(images/vm_logo.jpg);\"></div></div></div><center>" + "<button id=\"post_video_submit\" class=\"base_buttons\" style=\"margin-top:10px;\"></button>" + "</center></div></form>" + "<div class=\"gap\"></div>";


        var HTML = shut_box + header + middler;
        the_prompt.html(HTML);
        $("#close_prompt_vdo").click(function () {

            the_prompt.css('display', 'none');

        });

第一次代碼有效,即“ button hint_open”打開提示,而“ close me”按鈕關閉提示..但是第二次,當我單擊“ open提示符”按鈕時,沒有任何反應,即提示不顯示。 。

該怎么辦??

 the_prompt.attr('id', 'post_prompt'); 

是邪惡的路線。 你為什么要這么做? 這樣就不可能第二次選擇var the_prompt作為$("#Stuffprompt_main")

解決此問題的一些可能性:

  • 刪除該行(也許您實際上不需要它)
  • 移動var the_prompt = $("#Stuffprompt_main"); 分配到click處理程序之外,這樣就不會每次都執行(並且在更改ID時仍指向該元素)
  • 從close-click-handler重置id屬性

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM