Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 帕吉纳顿可以';不要选择原件_Javascript_Jquery_Html_Twitter Bootstrap - Fatal编程技术网

Javascript 帕吉纳顿可以';不要选择原件

Javascript 帕吉纳顿可以';不要选择原件,javascript,jquery,html,twitter-bootstrap,Javascript,Jquery,Html,Twitter Bootstrap,我的网页有一个问题,我的主要问题是引导和JQuery一起工作 $(“ul.pagination li:not(.active)a”)。在(“单击”,函数(){ $(“.pagination li.active”).removeClass(“active”); $(this.parent().addClass(“活动”); $(“.page”).hide(); $(“#”+$(this.text().toLowerCase()+“Page”).show();}) 将原始选择器

我的网页有一个问题,我的主要问题是引导和JQuery一起工作

$(“ul.pagination li:not(.active)a”)。在(“单击”,函数(){
$(“.pagination li.active”).removeClass(“active”);
$(this.parent().addClass(“活动”);
$(“.page”).hide();
$(“#”+$(this.text().toLowerCase()+“Page”).show();})


将原始选择器更改为

$("ul.pagination li a").on("click",function(){
否则,您不会绑定单击事件

$(“ul.pagination li a”)。在(“单击”,函数()上{
$(“.pagination li.active”).removeClass(“active”);
$(this.parent().addClass(“活动”);
$(“.page”).hide();
$(“#”+$(this.text().toLowerCase()+“Page”).show();})


这是因为您仅为非活动元素(不包括第一个活动元素)附加了
onclick
事件。您必须使所有元素都可单击,并检查单击的元素在处理程序中是否处于活动状态:

// Add a handler to all elements
$("ul.pagination li a").on("click",function(){
   var clicked = $(this);
   if(!clicked.parent().hasClass("active")) {
      // Do what you want
   }
});