Skip to content

Instantly share code, notes, and snippets.

@obi-a
Last active December 22, 2015 03:28
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 obi-a/6409877 to your computer and use it in GitHub Desktop.
Save obi-a/6409877 to your computer and use it in GitHub Desktop.
#document ready
jQuery ($) ->
#Set the size attribute of the zipcode field to 10
$("#zipcode").attr("size", "10")
#get size attribute for zipcode
zipcode_size = $("#zipcode").attr("size")
#Remove the size attribute from zipcode
$("#zipcode").removeAttr("size")
#get zipcode value
zipcode = $("#zipcode").val()
#set value of zipcode field
$("#zipcode").val("12345")
#get page title
title = $("title").text()
#get html of first h1
hdr = $("h1").html()
#turn h1 to black when clicked on
$("h1").click () ->
$(this).css("color", "black")
#turn background to gray when zipcode field loses focus
$("#zipcode").blur () ->
$(this).css("background-color", "gray")
#change zip code to 00000
do_something = () ->
$("#zipcode").val("00000")
#run the function do_something when h1 is double clicked
$("h1").bind('dblclick', do_something)
#trigger a doubleclick event on h1
$("h1").trigger("dblclick")
#trigger a form submission
$("#payment-form").trigger("submit")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment