user3086751 user3086751 - 5 months ago 10
ASP.NET (C#) Question

JavaScript failing on page postback

I have got this script to give effects to buttons which i have, it fails after the page is posted back, i have also put the code in a pageLoad method yet it still does not function. any idea how i can go about making this script run once the page has loaded.

$(document).ready(function () {

/*preloader for image loading bar*/

jQuery(function ($) {
function preLoad() {
//alert("script running");

function loaded() {
$('div#preLoader').css({ display: 'none' }).remove();

window.onload = loaded;

/* End of preloader*/

$("#btnPrevious").click(function (e) {
$("#btnNext").click(function (e) {

/* $(".qmatrix").click(function () {
//get id of button

$(".qmatrix").hover(function (e) {
//get id of button
//get src of image before hover
var origimage = $(this).attr('src');
// alert(origimage);
//$(this).attr({ src: 'images/questionMatrix/100' + $(this).attr('id') + '.png' });
$(this).stop().animate({ "opacity": "0.1" }, "fast")
function () {
// $(this).attr({ src: '' + origimage.toString() + '' });
$(this).stop().animate({ "opacity": "1" }, "fast");


The document.ready event is fired once the page has finished loading.

Inside the handler for the ready event, you're then using the ready event shortcut (passing a function directly to the global jQuery function (which is the same as the global $ function btw) to add another handler function for the ready event.

Inside this second ready handler you're then trying to assign the loaded function to window.onload, which would have already fired by this point.