Charl Crafford
Charl Crafford

Reputation: 1

Combining 2 different jquery functions

Am trying to combine two JQuery functions, but without any success.

if (querySt("photoid")) {
  var value = querySt("photoid");
   alert(value);
}

with

window.onload = function() {
  if(window.location.hash) {
    $(window.location.hash).trigger('click');
  }
};

Have tried the following:

if (querySt("photoid")) {   
  var value = querySt("photoid");
  window.onload = function() {
    if(window.location.value) {
      $('#' + window.location.value).trigger('click');
    }
  }
};  

Hash requires to be replaced with the actual '#' symbol. photoid returns the image id value like 415.

Any suggestion will be much appreciated.

Kind regards, Charl

Upvotes: 0

Views: 72

Answers (1)

Yograj Gupta
Yograj Gupta

Reputation: 9869

You should try this

window.onload = function() {

    if (querySt("photoid")) {
       var value = querySt("photoid");
       alert(value);
    }

    if(window.location.hash) {
        $(window.location.hash).trigger('click');
    }

};

Upvotes: 1

Related Questions