0
Follow
0
View

js click the question please see

cscwan 注册会员
2023-02-27 14:28
< div class = "md_content_show e397 data - v - 3967" = "" >

just didn't pay attention to see, are you using ajax inside. The HTML(); In this case, you need to use a delegate instead of listening directly. Your listening js should be:


const pageList = $("#page_list");
pageList.on('click', 'li.cli', function(event) {
  let  page = $(event.target).attr('data-page');
  $.ajax({
    url: "/ajax/",
    type: "GET",
    data: {'data' : page},
    dataType: "JSON",
    success: function (res) {
      if (res.status) {
        $('#cre').html(res.data);
        pageList.html(res.page)
      } else {
        alert("异常!")
      }
    }
  })
})

dt8095 注册会员
2023-02-27 14:28

Because when you listen for the click event, you prevent the element from doing what it does by default, that is, from clicking on the current element, so you comment that out and look at

img

edward840906 注册会员
2023-02-27 14:28

Excuse me elder brother this kind of event can monitor several times, repeated writing can be

danielssw 注册会员
2023-02-27 14:28
< div class = "md_content_show e397 data - v - 3967" = "" >

commented out Or useless

About the Author

Question Info

Publish Time
2023-02-27 14:28
Update Time
2023-02-27 14:28

Related Question

Nodejs aws-sdk v2读取AVRO文件

循环使用API提取的JSON元素

使用vuejs根据字符串内容显示数据集

我不能访问我的css和js文件在公共我的索引.HBS在视图文件夹

xhr携带formData发请求nodejs报500

一个变量在JS没有删除,但这里是没有错误?(复制)

无法将json引用数据传递给react组件

TongWeb8更新JSP不生效

Nginx反向代理返回json的问题

js里的style.display的应用 大学生