javascript - A selector switch id with jquery as condition -


perhaps easy ask, or maybe not. anyway, need call anchor of page link pressed, enters particular url particular anchor scroll down anchor.

i'm doing jquery this:

$(document).ready(function() {      var anchor = window.location.hash.substring(1);      if(anchor!="") {          var newanchor= "'#anchor-" +anchor+"'";          $(newanchor).trigger("click");      }  });      

i think not possible be, have never seen it, following error:

uncaught error: syntax error, unrecognized expression: '#anchor-2015' 

is possible call selector dynamically this? there way?

thank you.

yes it's possible. have wrong quotes.

$(document).ready(function() {      var anchor = window.location.hash.substring(1);   if(anchor!=""){      var newanchor= "#anchor-" + anchor;      $(newanchor).trigger("click");       }   });  

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -