jQuery: Run jQuery After Page Has Loaded OR how to check event after the page loaded in jquery?

jQuery(window).load(function () {
    alert('page is loaded');

    setTimeout(function () {
        alert('page is loaded and 1 minute has passed');   
    }, 60000);

});
Advertisements

get parant redio button images

<div class=”myimage” id=”myimage1″>
<a id=”bigImg” href=”” title=”robbie” class=”ajax quick-view-rob”>
<img class=”img1″ id=”img1″ src=”” height=”300″ />
</a>
</div>

 

jQuery(‘ul.options-list li input[type=”radio”]’).click(function() {
jQuery(‘#myimage1’).show();
var curImg = jQuery(this).parent().find(‘img’).attr(‘src’);
var curAnc = jQuery(this).parent().find(‘a’).attr(‘href’);
//alert(curAnc);
jQuery(‘#bigImg’).attr(‘href’, curAnc);
jQuery(‘#img1’).attr(‘src’, curImg);
//jQuery(‘.myimage’).show();

});

jQuery : Simple onclick email Validation function

<form method="post" name="form1" action="">

  <fieldset>
   <label>Email Address:</labe>
   <input type="text" name="UserEmail" id="UserEmail" value="" size="32" />
   <input type="submit" value="Submit" id="btn-submit" />
  </fieldset>
</form>

============================jQueyr fucnction=================================

$(document).ready(function() {

    $('#btn-submit').click(function() { 
        $(".error").hide();
        var hasError = false;
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        var emailaddressVal = $("#UserEmail").val();
        if(emailaddressVal == '') {
            $("#UserEmail").after('<span>Please enter your email address.</span>');
            hasError = true;
        }
        else if(!emailReg.test(emailaddressVal)) {
            $("#UserEmail").after('<span>Enter a valid email address.</span>');
            hasError = true;
        }
        if(hasError == true) { return false; }
    });
});

jQuery/Javascript page redirect with alternative


1
2
var your_url = 'https://nikunjvadariya.wordpress.com/'; //change this to your url
$(location).attr('href','your_url');

Above code works to redirect page in jQuery, but javascript code is good alternative here.

Using javascript to redirect your page using below code, which is better than jQuery, will do the job:

1
window.location.replace("https://nikunjvadariya.wordpress.com/");

Another javascript approach which will mock as if the URL is being clicked to redirect is:

1
window.location.href = "https://nikunjvadariya.wordpress.com/";

Even this will do the trick in javascript, which sets your URL in a window object and assigns it to anchor tag’s href attribute automatically:

1
window.location = "https://nikunjvadariya.wordpress.com/";