簡體   English   中英

無法從鏈接打開彈出窗口

[英]Cannot open popup from link

嗨,伙計們,我在從鏈接中通過 id 調用彈出窗口時遇到了一點問題。 它正在點擊,但無法從 url 調用類似 exaple.com/#id

 (function($) { $(document).ready(function() { //$('a.ajax-post').off('click').on('click', function(e) { $("a.ajax-post").on("click", function(e) { // show popup $(".popup.supernova").addClass("is-show"); e.preventDefault(); //Prevent Default Behaviour var post_id = $(this).attr("id"); //Get Post ID // Ajax Call $.ajax({ cache: false, timeout: 8000, url: "/wp-admin/admin-ajax.php", type: "POST", data: { action: "theme_post_example", id: post_id }, beforeSend: function() { $("#ajax-response").html("Loading"); }, success: function(data, textStatus, jqXHR) { var $ajax_response = $(data); $("#ajax-response").html($ajax_response); setTimeout(() => { $("#ajax-response").addClass("show-content"); }, 100); /* $(".popup.supernova").append(script); */ }, error: function(jqXHR, textStatus, errorThrown) { console.log( "The following error occured: " + textStatus, errorThrown ); }, complete: function(jqXHR, textStatus) {}, }); }); }); })(jQuery);
 <a href="#" id="8" class="catalog__item popup-8 ajax-post"> <span class="catalog__title">Title</span> <img src="image.jpg" alt="" id="img_8"> </a>

誰能告訴我該怎么做? 以及為什么它不起作用。 我是 js 新手。 提前致謝

根據您的問題,您想在URL容器 #id 像這樣exaple.com/#id時打開彈出窗口

您檢查 URL 是否包含#id,然后以編程方式單擊錨標記

暫無
暫無

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

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