You are here

js

Reload the page just Once

By using "localStorage" provided by HTML5:

<script type='text/javascript'>
(function()
{
  if( window.localStorage )
  {
    if( !localStorage.getItem( 'firstLoad' ) )
    {
      localStorage[ 'firstLoad' ] = true;
      window.location.reload();
    } 
    else
      localStorage.removeItem( 'firstLoad' );
  }
})();
</script>

jQuery and Select option

Get Selected Option From Dropdown:

var conceptName = $('#aioConceptName1').find(":selected").text();

Deselect all first:

$('id or class').removeAttr('selected');

To select option with value 'val':

$('.id option[value=val]').attr('selected','selected');

With modern code:

$('.id option[value=val]').prop('selected', true);

How to synchronize two SELECT elements:

Twistage Solution

<!DOCTYPE html>
<html>
<head>
<title>ATF Testing</title>

<script type="text/javascript" src="http://api2.twistage.com/api/script"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

<script type="text/javascript">
var videos = [ "twist1", "twist2" ];

var current = -1;

function toggleVid() {
current += 1;

if( current >= videos.length )
current = 0;

Pages