Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery .html does not work
    primarykey
    data
    text
    <p>Hey this is my first question on this website.</p> <p>Im creating a webpage for a client, this page needs to be loaded in 1 time and the user can navigate throught the different parts of the website using arrows, these arrows will activate a jquery script that will switch the HTML of a page...</p> <p>This is the Javascript i use:</p> <pre><code>&lt;script type="text/javascript"&gt; function loadPage(div){ if($("#page_"+div).length != 0){//if the page div exitst, else return false. var image = $("#image_"+div).attr('src'); var title = $("#title_"+div).html(); var info = $("#info_"+div).html(); $("#page").html('&lt;img src="'+image+'" /&gt;'); $("#title").html(title); alert($("#pageInfo").html()); return true; }else{ return false; } } $(document).ready(function(){ var div=1; loadPage(div); //&lt;buttons&gt; $("#btnHome").click(function(){ div = 1; loadPage(div); }); $("#btnPrevious").click(function(){ var success = loadPage((div-1)); if(success == true){ div--; } }); $("#btnNext").click(function(){ var success = loadPage((div+1)); if(success == true){ div++; } }); $("#btnInfo").click(function(){ $(".pageInfo").slideDown('fast'); }); $("#btnClose").click(function(){ $(".pageInfo").slideUp('fast'); }); //&lt;/buttons&gt; }); &lt;/script&gt; </code></pre> <p>And this is the html:</p> <pre><code> &lt;div id="page"&gt; &lt;div id="pageInfo"&gt; a &lt;/div&gt; &lt;/div&gt; </code></pre> <p>When i alert the variables i've set in Javascript i get the wished result, but when i alert:</p> <pre><code>alert($("#pageInfo").html()); </code></pre> <p>i get 'null' as a result, oh and JQuery is included.</p> <p>Can someone help me out with this information? Or did i miss essential parts. -edit: the rest of the HTML (sourcecode).</p> <pre><code>&lt;div id="wrapper"&gt; &lt;div class="pages" id="page_1"&gt; &lt;h1 id="title_1"&gt;Startpunt&lt;/h1&gt;&lt;img class="pagesImage" id="image_1" src="http://www.naviplan.nl/files/routefiles/1/1/67.jpg"&gt; &lt;div class="pagesInfo" id="info_1"&gt;INFO TEXT &lt;a data-role="button" id="btnClose" href="#" data-icon="arrow-u"&gt;Sluiten&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="pages" id="page_2"&gt; &lt;h1 id="title_2"&gt;Geen titel.&lt;/h1&gt;&lt;img class="pagesImage" id="image_2" src="http://www.jomaverhuur.nl/wp-content/uploads/2011/02/no-image.gif"&gt; &lt;div class="pagesInfo" id="info_2"&gt; &lt;a data-role="button" id="btnClose" href="#" data-icon="arrow-u"&gt;Sluiten&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="pages" id="page_3"&gt; &lt;h1 id="title_3"&gt;Geen titel.&lt;/h1&gt;&lt;img class="pagesImage" id="image_3" src="http://www.jomaverhuur.nl/wp-content/uploads/2011/02/no-image.gif"&gt; &lt;div class="pagesInfo" id="info_3"&gt; &lt;a data-role="button" id="btnClose" href="#" data-icon="arrow-u"&gt;Sluiten&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="pages" id="page_4"&gt; &lt;h1 id="title_4"&gt;Geen titel.&lt;/h1&gt;&lt;img class="pagesImage" id="image_4" src="http://www.jomaverhuur.nl/wp-content/uploads/2011/02/no-image.gif"&gt; &lt;div class="pagesInfo" id="info_4"&gt; &lt;a data-role="button" id="btnClose" href="#" data-icon="arrow-u"&gt;Sluiten&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="pages" id="page_5"&gt; &lt;h1 id="title_5"&gt;Geen titel.&lt;/h1&gt;&lt;img class="pagesImage" id="image_5" src="http://www.jomaverhuur.nl/wp-content/uploads/2011/02/no-image.gif"&gt; &lt;div class="pagesInfo" id="info_5"&gt; &lt;a data-role="button" id="btnClose" href="#" data-icon="arrow-u"&gt;Sluiten&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="pages" id="page_6"&gt; &lt;h1 id="title_6"&gt;Geen titel.&lt;/h1&gt;&lt;img class="pagesImage" id="image_6" src="http://www.jomaverhuur.nl/wp-content/uploads/2011/02/no-image.gif"&gt; &lt;div class="pagesInfo" id="info_6"&gt; &lt;a data-role="button" id="btnClose" href="#" data-icon="arrow-u"&gt;Sluiten&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="pages" id="page_7"&gt; &lt;h1 id="title_7"&gt;Eindpunt&lt;/h1&gt;&lt;img class="pagesImage" id="image_7" src="http://www.naviplan.nl/files/routefiles/1/17/finish56.png"&gt; &lt;div class="pagesInfo" id="info_7"&gt; &lt;a data-role="button" id="btnClose" href="#" data-icon="arrow-u"&gt;Sluiten&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div data-role="header" data-position="inline" data-position="fixed" &gt; &lt;a id="btnHome" href="#" data-icon="home"&gt;Homepage&lt;/a&gt; &lt;h1 id="title"&gt;&lt;/h1&gt; &lt;/div&gt; </code></pre> <p>Greetings, Harm.</p> <p><em>(im sorry if this question is already asked, but i dont know where to search for.)</em></p>
    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.
    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