js
//Here is you normal twitter button code
//My custom function
function mycustom() {
alert('this is a test')
}//Bind the custom function with twitter event
twttr.ready(function (twttr) {
twttr.events.bind('click', mycustom);
});Checking if cookie value is equal to ...
Setting up the cookie:
$.cookie("userAgeValue", "userUnder21", { path: '/' });Checking if value = "userUnder21":
if($.cookie('userAgeValue') == 'userUnder21') {
//do something;
}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>JavaScript - Get Portion of URL Path
There is a property of the built-in window.location object that will provide that for the current window.
// If URL is http://www.somedomain.com/account/search?filter=a#top
window.location.pathname // /account/search
// For reference:
var selectedState = $('#field_state').find(":selected").text();
$('#edit_profile_page #tab3selector a').on('click', function () {
$('#html_state option[value="' + selectedState + '"]').trigger('change');
});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:
Remove hyperlink but keep text?
<a href="http://www.website.com/something" title="Show Profile">Mentalist</a>Solution:
$('a[title="Show Profile"]').contents().unwrap();Focus on search form when click on toggle
/*Focus on search form when click on toggle*/
$('.toggle-header-index a').click(function () {
$("#search-block-form .form-control").focus().attr("placeholder", "Enter the terms you wish to search for.");
});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;
Bootstrap Tooltip Plugin
