嗨,伙计们,我有一个小问题,打电话弹出的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>
有人能告诉我怎么做吗?以及为什么它不起作用。我是新来的。提前感谢
发布于 2020-07-22 10:47:04
根据您的问题,当exaple.com/#id URL容器#id时,您希望打开
检查URL是否包含#id,然后单击锚标记Programmatically
https://stackoverflow.com/questions/63031523
复制相似问题