<script>
function Show(divId)
{
if(document.getElementById(divId).style.display == 'none')
{
document.getElementById(divId).style.display='block';
}
else
{
document.getElementById(divId).style.display = 'none';
}
}
</script>
<a onclick ="javascript : Show('Show_1')" href="javascript:;">The First Name</a></li>
<div id="Show_1">The First Name - Information here</div>
<a onclick ="javascript : Show('Show_2')" href="javascript:;">The Second Name</a></li>
<div id="Show_2">The Second Name - Information here</div>
<a onclick ="javascript : Show('Show_3')" href="javascript:;">The Third Name</a></li>
<div id="Show_3">The Third Name - Information here</div>
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.js"></script>
<script type='text/javascript'>
//<![CDATA[
$(window).load(function(){
$(".myLink").click(function(){
var me = $(this),
data = me.data('key');
$( "div").toggle( "slow" );
console.log(data);
//$('body').append(data.Param1);
});
});//]]>
</script>
<a class='myLink' href='#' data-key='{"Param1":"ShowMyZones_1"}' >Link One</a> |
<a class='myLink' href='#' data-key='{"Param2":"ShowMyZones_2"}' >Link Two</a>
<div id="ShowMyZones_1" style="display:none;">information here, for ONE!</div>
<div id="ShowMyZones_2" style="display:none;">information here, for TWO!</div>
ASKER
ASKER
ASKER
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.js"></script>
<script type='text/javascript'>
$(window).load(function(){
$(".myLink").click(function(){
//The following line hide a div that is already visible
$('div:visible').toggle("slow");
var me = $(this),
data = me.data('key');
var flag=data.Param;
//After I took the key i am using it to the following line to target the desire div with the id selector;
//I use sessionStorage to create and store a key-value pair in the sessionStorage
//Then I use an if condition to check if exist or no the value and then if is no the code is executing
//Remember that sessionStorage keeps the key-value until you close the tab of the browser
if(sessionStorage[data.Param]==null){
$("#"+data.Param).toggle( "slow" );
}
sessionStorage[data.Param]=data.Param;
console.log(sessionStorage);
});
});
</script>
<div>
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_1"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_2"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_3"}' >Link 3</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_4"}' >Link 4</a>
<div id="ShowMyZones_1" style="display:none;">information here, for ONE!</div>
<div id="ShowMyZones_2" style="display:none;">information here, for TWO!</div>
<div id="ShowMyZones_3" style="display:none;">information here, for 3!</div>
<div id="ShowMyZones_4" style="display:none;">information here, for 4!</div>
</div>
<div>
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_1"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_2"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_3"}' >Link 3</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_4"}' >Link 4</a>
<div name="link" id="ShowMyZones_1" style="display:none;">information here, for ONE!</div>
<div name="link" id="ShowMyZones_2" style="display:none;">information here, for TWO!</div>
<div name="link" id="ShowMyZones_3" style="display:none;">information here, for 3!</div>
<div name="link" id="ShowMyZones_4" style="display:none;">information here, for 4!</div>
</div>
$(window).load(function(){
$(".myLink").click(function(){
//The following line hide a div with name=link that is already visible
$('div[name="link"]:visible').toggle("slow");
var me = $(this),
data = me.data('key');
var flag=data.Param;
//After I took the key i am using it to the following line to target the desire div with the id selector;
//I use sessionStorage to create and store a key-value pair in the sessionStorage
//Then I use an if condition to check if exist or no the value and then if is no the code is executing
//Remember that sessionStorage keeps the key-value until you close the tab of the browser
if(sessionStorage[data.Param]==null){
$("#"+data.Param).toggle( "slow" );
}
sessionStorage[data.Param]=data.Param;
console.log(sessionStorage);
});
});
ASKER
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.js"></script>
<script type='text/javascript'>
$(window).load(function(){
$(".myLink").click(function(){
//The following line hide a div with name=link that is already visible
$('div[name="link"]:visible').toggle("slow");
var me = $(this),
data = me.data('key');
var flag=data.Param;
//After I took the key i am using it to the following line to target the desire div with the id selector;
//I use sessionStorage to create and store a key-value pair in the sessionStorage
//Then I use an if condition to check if exist or no the value and then if is no the code is executing
//Remember that sessionStorage keeps the key-value until you close the tab of the browser
if(sessionStorage[data.Param]==null){
$("#"+data.Param).toggle( "slow" );
}
sessionStorage[data.Param]=data.Param;
console.log(sessionStorage);
});
});
</script>
<div>
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_1"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_2"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_3"}' >Link 3</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_4"}' >Link 4</a>
<div name="link" id="ShowMyZones_1" style="display:none;">information here, for ONE!</div>
<div name="link" id="ShowMyZones_2" style="display:none;">information here, for TWO!</div>
<div name="link" id="ShowMyZones_3" style="display:none;">information here, for 3!</div>
<div name="link" id="ShowMyZones_4" style="display:none;">information here, for 4!</div>
</div>
<div>
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_1"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_2"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_3"}' >Link 3</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_4"}' >Link 4</a>
<div class="link" id="ShowMyZones_1" style="display:none;">information here, for ONE!</div>
<div class="link" id="ShowMyZones_2" style="display:none;">information here, for TWO!</div>
<div class="link" id="ShowMyZones_3" style="display:none;">information here, for 3!</div>
<div class="link" id="ShowMyZones_4" style="display:none;">information here, for 4!</div>
</div>
$(window).load(function(){
$(".myLink").click(function(){
//The following line hide a div with name=link that is already visible
$('div.link:visible').toggle("slow");
var me = $(this),
data = me.data('key');
var flag=data.Param;
//After I took the key i am using it to the following line to target the desire div with the id selector;
//I use sessionStorage to create and store a key-value pair in the sessionStorage
//Then I use an if condition to check if exist or no the value and then if is no the code is executing
//Remember that sessionStorage keeps the key-value until you close the tab of the browser
if(sessionStorage[data.Param]==null){
$("#"+data.Param).toggle( "slow" );
}
sessionStorage[data.Param]=data.Param;
console.log(sessionStorage);
});
});
ASKER
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.1.js"></script>
<script type='text/javascript'>
$(window).load(function(){
$(".myLink").click(function(){
//The following line hide a div with name=link that is already visible
$('div.link:visible').toggle("slow");
var me = $(this),
data = me.data('key');
var flag=data.Param;
//After I took the key i am using it to the following line to target the desire div with the id selector;
//I use sessionStorage to create and store a key-value pair in the sessionStorage
//Then I use an if condition to check if exist or no the value and then if is no the code is executing
//Remember that sessionStorage keeps the key-value until you close the tab of the browser
if(sessionStorage[data.Param]==null){
$("#"+data.Param).toggle( "slow" );
}
sessionStorage[data.Param]=data.Param;
console.log(sessionStorage);
});
});
</script>
<div>
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_1"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_2"}' >Link Text</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_3"}' >Link 3</a> |
<a class='myLink' href='#' data-key='{"Param":"ShowMyZones_4"}' >Link 4</a>
<div class="link" id="ShowMyZones_1" style="display:none;">information here, for ONE!</div>
<div class="link" id="ShowMyZones_2" style="display:none;">information here, for TWO!</div>
<div class="link" id="ShowMyZones_3" style="display:none;">information here, for 3!</div>
<div class="link" id="ShowMyZones_4" style="display:none;">information here, for 4!</div>
</div>
ASKER
Storage
ShowMyZones_1
:
"ShowMyZones_1"
ShowMyZones_2
:
"ShowMyZones_2"
ShowMyZones_3
:
"ShowMyZones_3"
ShowMyZones_4
:
"ShowMyZones_4"
length
:
4
__proto__
:
Storage
ASKER
ASKER
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
HTML:
Open in new window
JQuery code (comments inside)
Open in new window