and weird questions, please ask the gods to answer them_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:18:30
Original
785 people have browsed it

jquery ajax






<%--内容--%>


    


        


        
            
                
                
                
            
            
        
Id Category Name
暂无数据!



< 首页 上一页 
下一页 尾页 >



 'table>tbody>tr>td').remove();
$.post('dataServers.ashx', { ccid: "h_xuxu" }, function(data) {
var html = '';
for (i = xshs * ymsy; i < xshs * (ymsy 1); i ) {
html = '' data[i].id ' t ;' data[i].category '' data[i].name ''; ('.gridtable1').append(html);
}, 'json');
}
//Last page processing
function lastaaa(xshs, ymsy, zhs) {
$('table>tbody>tr>td').remove();
$.post('dataServers.ashx', { ccid: "h_xuxu" }, function(data) {
var html = ' ';
for (i = xshs * ymsy; i td>' data[i].category '' data[i].name ''; gridtable1').append(html);
}, 'json');
}
/*Page turning method*/
//Page turning core method
function fanYe(scc, sclen, htmSpan) {
for (var i = scc; i <= sclen; i ) {
htmSpan = '[' i '] }
$('#sp1').append(htmSpan);
}
//Initialize page turning
function fy(zhs, xshs, ymsy, cs) {
//Determine whether the page is larger than 10 pages
var htmSpan = '';
if (zhs / xshs > 10 * cs - 1) {
//Loading displays 1-10span
fanYe(ymsy 1, 10 * cs, htmSpan);
} else {
          fanYe(ymsy 1, parseInt(zhs /  xshs)   1, htmSpan); 🎜> // Click the next page to turn the page
function nfy(zhs, xshs, ymsy, cs) {
var htmSpan = "";
if (ymsy == 10 * cs) {
//If there is The next ten pages
if (parseInt(zhs / xshs) > 10 * (cs 1) - 1) {
$('#sp1>span').remove();
h tmSpan = '' ;
                                                                                                                                                                                                                                  } else if (zhs % xshs == 0 && zhs / (xshs * 10) > cs) {
        $('#sp1>span').remove();
                                    🎜 > fanYe(ymsy 1, ymsy 10, htmSpan);
// == 0 && zhs / (xshs * 10) == cs) {
                                                                                     move() ;
htmSpan = '';
fanYe(ymsy 1, parseInt(zhs / xshs) 1, htmSpan);
                 alert('<' cs);
}
//Display page number
function xsym(ymsy) {
//Page number ymym
ymym = ymsy 1;
//Move out other pages selected
$( '#sp1>span').removeClass('selected');
//Initial current page number ymsy 1
$('#sp1>span.i' ymym '').addClass("selected") ;
}
The problem encountered is that when $('#Button1') is clicked for the first time, the code logic is normal and the page can be turned normally. When $('#Button1') is clicked again, ymsy The value cannot be reset to 0. Clicking the next page will trigger the next page event twice. Please ask a jQuery expert for an answer! ! !


Reply to the discussion (solution)

When binding an event repeatedly, you should determine whether the event has already been bound. You can use global variables to determine.

When binding an event repeatedly, you should determine whether the event has already been bound. You can use global variables to determine.
How to judge specifically, please explain in detail

Quoting the reply from datiexiong on the 1st floor: If you bind an event repeatedly, you should judge whether the event has been bound. You can use global variables to judge. .

How to judge specifically, please explain in detail

var button1Click = false;

$('#Button1').click(function(){
if(!buttonClick)

{

buttonClick=true;
//Code of the original bound event
}
});

Quote from 2nd Floor h_xuxu's reply: Quote from 1st Floor datiexiong's reply: Duplicate binding For events, it should be judged whether the event has been bound. You can use global variables to judge.
How to judge specifically, please explain in detail
var button1Click = false;
$('#Button1').click(function(){
if(!buttonClick)
{
buttonClick=true;

……

This can solve the confusion caused by multiple clicks on $('#Button1'). How to change it if you want to click on $('.btn')? Just click on a type of button? Let him execute it.

Quoted from the 3rd floor datiexiong's reply: Quoted from the 2nd floor h_xuxu's reply: Quoted from the 1st floor datiexiong's reply: When binding an event repeatedly, you should judge whether the event has already been bound. You can use global variables to judge.
How to judge specifically, please explain in detail
var button1Click = false;
$('#Button1').click(function(){
if(!buttonClic...
Can give btn adds attributes, using setAttribute("clicked",true),
When getAttribute("clicked") is false or undefined, it is considered that it has not been bound, otherwise the task has been bound.

Quote from 4th floor h_xuxu's reply: Quote from 3rd floor datiexiong's reply: Quote from 2nd floor h_xuxu's reply: Quote from 1st floor datiexiong's reply: If you repeatedly bind an event, you should determine whether the event has been bound. You can use global variables to judge.
How to judge specifically, please explain in detail
var button1Click = false;
$('#Button1').click(function(){...
Thank you very much, I will go to the next page , the next page, the first page, and the last page were solved after adding $(element).unbind('click');$(element).bind('click'); respectively. ThankYou.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template