Note that there are some explanatory texts on larger screens.

plurals
  1. POload content from external file javascript
    primarykey
    data
    text
    <p>I want to load div which's id equal to id <code>('#content'+divId)</code> for example button's <code>id=1</code> and it must load content from <code>file.php</code> which div id equal to content_1 and button's <code>id=2</code> and it must load content from <code>file.php</code> which div id equal to content_2. both content loads form the same file and it must be shown in different divs.</p> <p>here is my js</p> <pre><code>$(document).ready(function() { var hash = window.location.hash.substr(1); var href = $('#nav li a').each(function(){ var href = $(this).attr('href'); if(hash==href.substr(0,href.length-4)){ var toLoad = hash+'.html #content_low'+divId; $('#content'+divId).load(toLoad); alert(divId); } }); $('#nav li a').click(function(){ divId = $(this).parents('li').attr('id'); var toLoad = $(this).attr('href')+'#content_low'+divId; alert(divId); $('#content'+divId).slideUp('normal',loadContent).delay(200); window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-$(this).attr('href').length); function loadContent() { $('#content'+divId).load(toLoad,showNewContent) } function showNewContent() { $('#content'+divId).delay(700).slideDown($('#content'+divId).height()); } return false; }); }); </code></pre> <p>here is html</p> <pre><code>&lt;ul id="nav" class="marketlist"&gt;&lt;li id="1" class="market twobox"&gt; &lt;a href="external_file.php"&gt;&lt;img src="img/projects/1.jpg" class="items" alt="" /&gt;&lt;/a&gt; &lt;/li&gt;&lt;li id="2" class="market"&gt; &lt;a href="external_file.php"&gt;&lt;img src="img/projects/1.jpg" class="items" alt="" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload