views:

17

answers:

2

Hey. I'm loading content dynamically like this:

  $("#id a").click(function(e){ 
     e.preventDefault(); 
     var hash = this.parentNode.hash;
        $("#show").load('files/'+ hash +'.html'); 
        $("#show").fadeIn(300);     
 }); 

But the hash is #first, #second, #third so I have to name files #first.html, #second.html etc. How to edit hash string and cut the # thing, so I'll be able to load files named first.html, second.html etc. without the hash (#) sign?

A: 

Use substr, substring, or slice.

'files/' + hash.substring(1) + '.html'

or

hash.slice(1)

or

hash.substr(1)
Anurag
A: 
 $("#id a").click(function(e){ 
     e.preventDefault(); 
     var hash = this.parentNode.hash;
        $("#show").load('files/'+ hash.replace('#','') +'.html'); 
        $("#show").fadeIn(300);     
 }); 
Michael Robinson