There is a working function

function ocmenu( p ){ $( "#container2" ).load( "1.html #content" ); } 

I am trying to transfer the html number of the page "1" using a variable from my own site, but nothing works. Tried through string concatenation - complete vanity.

 $( "#container2" ).load( \""\" +p+ ".html" + " " + "#content" + \""\" ); 

Variable pass through onclick

 <p onclick="ocmenu('1')">ClickClack</p> 
  • $ ("# container2") .load (p + ".html #content"); p + ".html #content" - should convert to a string and you get a valid parameter for load - Khotey Vitaliy
  • Thank you very much! Earned, it turned out to be still easier;) - Dmitry
  • too many escapes, too many quotes - Grundy

1 answer 1

since the dynamic part of the line, just at the beginning you can use the advice from the comment

 p + ".html #content" 

In the case when there are several substitutions in different places, you can use templates that were added in ES2015 (do not work in IE)

In this case, they would look like this:

 `${p}.html #content`