jquery not working with more than 1 function

al123

I have created a click function on an ASPX page which worked fine, when I moved the code to my site.master which has a existing J query function it doesn't seem to work.

this is my J query function I created:

var scrolled = 0;
$(document).ready(function () {
    try {
        $("#downClick").on("click", function () {
            scrolled = scrolled + 235;

            $(".cover").stop().animate({
                scrollTop: scrolled
            });

        });
        $("#upClick").on("click", function () {
            scrolled = scrolled - 235;

            $(".cover").stop().animate({
                scrollTop: scrolled
            });

        });
        $(".clearValue").on("click", function () {
            scrolled = 0;
        });
    } catch (e) { }
});

However, when I tried adding this to my main site, in the site.master, it just refreshes the page when I click more booklets.

Clearly the code works but something in the site.master making the page refresh.

I have another J query function in the site.master which I think may be causing this:

$(document).ready(function () {
    try {
        $('.slider1').bxSlider({
            slideWidth: 960,
            captions: true,
            auto: true,
            autoControls: true
        });
    } catch (e) { }
});

This is a slider on the page, but with the previous code added it doesn't work.

Any ideas why the first code doesn't work in my main page, am assuming its because threes other Jquery functions but still not sure why it refreshes. any help would be much appreciated.

user1017882

You're using buttons inside a form; the button is causing a postback. Perfectly normal.

Instead, use an input of type button. Rewrite:

<button id="downClick">More Booklets</button>

So that it reads:

<input id="downClick" type="button" value="More Booklets" />

Your jQuery selectors are based on the id, so it'll still handle the click events as you'd expect.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery function working with more data

From Dev

jquery autocomplete not working for more than one result

From Dev

More than 1 instance of annotation not working in Acrobat

From Dev

more than one function from jquery ui

From Dev

Fire Up jQuery function more than once

From Dev

Regex combine more than 1 function

From Dev

jquery rotate more than 1 element at a time

From Dev

JQuery - Adding More Than 1 Attachment

From Dev

jquery display:block not working correclty when more than 2 divs

From Dev

Search is actually working but returning more than 1 value

From Dev

RxJS: forkJoin delay seems not working on more than 1 call

From Dev

How to stop the jQuery .load() function from firing more than once?

From Dev

Perform click function on same id at more than once using jquery

From Dev

More than one drop down messing up jQuery / Bootstrap function

From Dev

Shorthand for calling a function with an argument more than once in JavaScript/jQuery?

From Dev

How can I have more than one click function in jQuery?

From Dev

jQuery function for more than one image preview before upload

From Dev

jquery remove function and removing more than one element

From Dev

Anchor tag with jQuery function doesn't initiate more than once

From Dev

jquery dynamically added divs firing a function more than once

From Dev

jQuery Validate Custom Function - More than Minimum Value

From Dev

Only execute function if mouse has hovered for more than 1 second

From Dev

Customized aggregation function with more than 1 input in dcast

From Dev

Using more than 1 function in-line from class

From Dev

QtConcurrent::blockingMapped calling function with more than 1 argument

From Dev

mail() function not send more than 1mb attachment in php

From Dev

Delete function fails when there is more than 1 marker on Google Maps

From Dev

jquery if children has more than 1 div element

From Dev

How to animate more than 1 item from the same div in jQuery?

Related Related

  1. 1

    jQuery function working with more data

  2. 2

    jquery autocomplete not working for more than one result

  3. 3

    More than 1 instance of annotation not working in Acrobat

  4. 4

    more than one function from jquery ui

  5. 5

    Fire Up jQuery function more than once

  6. 6

    Regex combine more than 1 function

  7. 7

    jquery rotate more than 1 element at a time

  8. 8

    JQuery - Adding More Than 1 Attachment

  9. 9

    jquery display:block not working correclty when more than 2 divs

  10. 10

    Search is actually working but returning more than 1 value

  11. 11

    RxJS: forkJoin delay seems not working on more than 1 call

  12. 12

    How to stop the jQuery .load() function from firing more than once?

  13. 13

    Perform click function on same id at more than once using jquery

  14. 14

    More than one drop down messing up jQuery / Bootstrap function

  15. 15

    Shorthand for calling a function with an argument more than once in JavaScript/jQuery?

  16. 16

    How can I have more than one click function in jQuery?

  17. 17

    jQuery function for more than one image preview before upload

  18. 18

    jquery remove function and removing more than one element

  19. 19

    Anchor tag with jQuery function doesn't initiate more than once

  20. 20

    jquery dynamically added divs firing a function more than once

  21. 21

    jQuery Validate Custom Function - More than Minimum Value

  22. 22

    Only execute function if mouse has hovered for more than 1 second

  23. 23

    Customized aggregation function with more than 1 input in dcast

  24. 24

    Using more than 1 function in-line from class

  25. 25

    QtConcurrent::blockingMapped calling function with more than 1 argument

  26. 26

    mail() function not send more than 1mb attachment in php

  27. 27

    Delete function fails when there is more than 1 marker on Google Maps

  28. 28

    jquery if children has more than 1 div element

  29. 29

    How to animate more than 1 item from the same div in jQuery?

HotTag

Archive