Skip to content

Instantly share code, notes, and snippets.

@Fab1en
Last active December 15, 2015 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fab1en/5258377 to your computer and use it in GitHub Desktop.
Save Fab1en/5258377 to your computer and use it in GitHub Desktop.
Three means to display help content.
.hidden{ display: none; }
<div id="page">
<div id="display">
<h1>Info</h1>
<p>Some text</p>
</div>
<button id="help1">Show help (embedded)</button>
<button id="help2">Show help (json)</button>
<button id="help3">Show help (html ajax)</button>
<div class="hidden" id="help-content">
<h1>Help</h1>
<p>Here is the embedded version help content</p>
<a href="http://www.dailymotion.com/video/x309hk_the-beatles-help_music">Help link</a>
</div>
</div>
jQuery(function($){
$('#help1').click(function(){
// get content from local DOM
$('#display').html($('#help-content').html());
});
$('#help2').click(function(){
// get content from remote JSON file
$.get('/gh/gist/response.json/5258377', function(data){
$('#display').html(data.help);
}, 'json');
});
$('#help3').click(function(){
// get content from remote HTML file + select by id
$('#display').load('/gh/gist/response.html/5258377 #help-content');
});
});
name: Three means to display help content
<div id="page">
<div id="help-content">
<h1>Help</h1>
<p>Here is the ajax html version help content</p>
<a href="http://www.dailymotion.com/video/x309hk_the-beatles-help_music">Help link</a>
</div>
</div>
{"help":"<h1>Help<\/h1><p>Here is the JSON version of the help content<\/p><a href=\"http:\/\/www.dailymotion.com\/video\/x309hk_the-beatles-help_music\">Help link<\/a>"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment