IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » js The latest public js snipts.

showing 1-20 of 73 snipts for js
  • JS: onfocus and onblur
    $("#email").focus(function() {
        if ($(this).val() == $(this).attr('rel'))
            $(this).val('');
    });
    $("#email").blur(function() {
        if ($(this).val() == '')
            $(this).val($(this).attr("rel"));
    });
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Sep 01, 2010 at 9:54 p.m. EDT
  • JS: onload fix for resetting when back button is used
    <script>
    // reset fix for selectbox when the back button is used
    // place this code in the body, not the head.
    window.onload = function(){
        $('#selectbox1').val('');
        $('#selectobx2').val('');
        };
    </script>
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Aug 06, 2010 at 11:47 a.m. EDT
  • jquery external liks
    <!--JQUERY LINKS-->
    
    <!--LATEST FROM JQUERY-->
    <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
    
    <!--VERSION 1.4.2 FROM GOOGLE-->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> 
    
    <!--LATEST VERSION 1.X.X FROM GOOGLE-->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> 
    
    
    
    <!--This is the official jQuery Tools UI library and after the inclusion you will have the following tools available:
    
    jQuery 1.4.2
    Tabs
    Tooltip
    Scrollable
    Overlay-->
    <script src="http://cdn.jquerytools.org/1.2.3/jquery.tools.min.js"></script>
    

    copy | embed

    0 comments - tagged in  posted by aike on Jun 30, 2010 at 6:27 a.m. EDT
  • javascript back
    <a href="javascript:history.back()">Back</a>
    

    copy | embed

    0 comments - tagged in  posted by aike on Jun 30, 2010 at 5:49 a.m. EDT
  • alternate way to deal with hiding modal boxes when clicking anywhere outside
    // attach the general handler for all clicks
    $(document).bind("click.hidepopups", function(ev){
        $(".modal").fadeOut(200, function(){ $(this).remove(); });
    });
    
    // set up the trigger to show the modal box/menu
    $(trigger).click(function(e){
        $(document).trigger("click.hidepopups"); // hide existing modals
    
        var div = $("<div class=\"box modal\">This is a box</div>");
    	div.bind('click', function(ev){ ev.stopPropagation(); });
    
        $(document.body).append(div.fadeIn(200)); // make new modal
        e.stopPropagation();
    });
    

    copy | embed

    0 comments - tagged in  posted by aditya on Jun 29, 2010 at 11:29 a.m. EDT
  • pseudo-code to handle ignoring JS modal boxes by clicking outside the box
    /* trigger: 		   whatever triggers the modal box
     * modalBoxTopmostWrapper: the root wrapper of the modal box
     */
    
    $(trigger).click(function(event){
    	
        /* show modal box */
    
        $(document).bind("click.confirmation", function(e){
            if( $(e.target).parents(modalBoxTopmostWrapper).length ) // stop if clicking the confirmation box
                return;
    		
    	/* close modal box */
    		
            $(document).unbind("click.confirmation");
        });
        event.stopPropagation(); // to prevent click.confirmation from firing immediately
    });
    

    copy | embed

    0 comments - tagged in  posted by aditya on Jun 29, 2010 at 8:06 a.m. EDT
  • JS: prepend ajax text to url
    function addAjax(origHref)
    {
        //var origHref = $('.add-student').attr('href');
        var urlArray = origHref.split(/[\/]/);
        if (urlArray.length > 1)
        {
            var filename = urlArray.pop();
            // if there's a trailing slash, get the next iteration
            if (filename.length < 1) filename = urlArray.pop();
            filename = "/ajax-" + filename;
            return urlArray.join("/") + filename;
        }
        return origHref;
    }
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Jun 22, 2010 at 10:50 a.m. EDT
  • js
    $('#numberedNutmeg').addAnnotations(function(annotation){
      return $(document.createElement('span')).
        addClass('black circle note').html(annotation.position);
    },[
        {x: 0.3875, y: 0.3246, position: 4},
        {x: 0.57, y: 0.329, position: 2}
      ]
    );
    

    copy | embed

    0 comments - tagged in  posted by comsharp on Jun 15, 2010 at 6:42 p.m. EDT
  • Asyhcronous Google Analytics Code
    <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXX-X']);
      _gaq.push(['_trackPageview']);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
      })();
    
    </script>
    

    copy | embed

    0 comments - tagged in  posted by benjamin on Jun 10, 2010 at 9:51 a.m. EDT
  • companion cube
    $('#emergencyIntelligenceIncinerator').bind('textchange', function () {
      if ($(this).val().indexOf('companion cube') !== -1) {
        $('#continue').removeClass('disabled').attr('disabled', false);
      }
    });
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Jun 03, 2010 at 9:05 p.m. EDT
  • AJAX save
    var timeout;
    $('#ajaxSave').bind('textchange', function () {
      clearTimeout(timeout);
      $('#ajaxFired').html('<strong>Typing...</strong>');
        var self = this;
        timeout = setTimeout(function () {
        $('#ajaxFired').html('<strong>Saved</strong>: ' + $(self).val());
      }, 1000);
    });
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Jun 03, 2010 at 8:47 p.m. EDT
  • twitter text change
    $('#twitter').bind('textchange', function (event, previousText) {
      $('#charactersLeft').html( 140 - parseInt($(this).val().length) );
    });
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Jun 03, 2010 at 8:20 p.m. EDT
  • exhibitb
    $('#exhibitb').bind('textchange', function (event, previousText) {
      $('#output').append('<p>Text changed from <strong>' + 
        previousText + '</strong> to <strong>' + $(this).val() + 
        '</strong> </p>');
    });
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Jun 03, 2010 at 8:09 p.m. EDT
  • textchange link
    <script src="/javascripts/plugins/jquery.textchange.js"></script>
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Jun 03, 2010 at 7:18 p.m. EDT
  • exhibita
    $('#exhibita').bind('hastext', function () {
      $('#exhibitaButton').removeClass('disabled').attr('disabled', false);
    });
    	
    $('#exhibita').bind('notext', function () {
      $('#exhibitaButton').addClass('disabled').attr('disabled', true);
    });
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Jun 03, 2010 at 6:53 p.m. EDT
  • Highlight all div elements on page
    javascript:var%20eL=document.getElementsByTagName('div');for(i=0;i%3CeL.length;i++)%7Bvoid(eL%5Bi%5D.style.border='solid%201px%20red')%7D
    

    copy | embed

    0 comments - tagged in  posted by splorp on May 04, 2010 at 10:16 p.m. EDT
  • Toggle all checkboxes on page
    javascript:var%20fR=document.getElementsByTagName('frame');if(fR.length%3E0)for(f=0;f%3CfR.length;f++)%7Bvar%20eL=top.frames%5Bf%5D.document.getElementsByTagName('input');for(i=0;i%3CeL.length;i++)%7Bif(eL%5Bi%5D.checked==false)void(eL%5Bi%5D.checked=true);else%7Bvoid(eL%5Bi%5D.checked=false);%7D%7D%7Delse%7Bvar%20eL=document.getElementsByTagName('input');for(i=0;i%3CeL.length;i++)%7Bif(eL%5Bi%5D.checked==false)void(eL%5Bi%5D.checked=true);else%7Bvoid(eL%5Bi%5D.checked=false);%7D%7D%7D
    

    copy | embed

    0 comments - tagged in  posted by splorp on May 04, 2010 at 10:05 p.m. EDT
  • fizz buzz
    <script type="text/javascript">
    	$(document).ready(function(){
    		var i = 1;
    		do {
                if(i%3 == 0){
                    $('#container').append("Fizz"); 
                }
                if(i%5 == 0){
                    $('#container').append("Buzz"); 
                }
                
                $('#container').append(i); 
                i++;
            } while ( i <= 100);	
    	});
    </script>
    

    copy | embed

    0 comments - tagged in  posted by idesignmotion on Apr 28, 2010 at 2:04 p.m. EDT
  • include annotate
    <script src="/javascripts/plugins/jquery.js"></script>
    <script src="/javascripts/plugins/jquery.annotate.js"></script>
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Apr 16, 2010 at 5:35 p.m. EDT
  • serialize
    $('#nutmeg span.note').seralizeAnnotations();
    

    copy | embed

    0 comments - tagged in  posted by mkelly12 on Apr 16, 2010 at 5:24 p.m. EDT
Sign up to create your own snipts, or login.