{"id":186,"date":"2014-04-02T17:07:54","date_gmt":"2014-04-02T17:07:54","guid":{"rendered":"https:\/\/learnwebcode.com\/?p=186"},"modified":"2016-03-15T03:55:52","modified_gmt":"2016-03-15T03:55:52","slug":"jquery-variables-functions-and-conditional-logic","status":"publish","type":"post","link":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/","title":{"rendered":"jQuery Variables, Functions, and Conditional Logic"},"content":{"rendered":"<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"http:\/\/www.youtube.com\/embed\/gIvR-WX5lIQ?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>This lesson picks up where our original <a href=\"https:\/\/learnwebcode.com\/javascript-and-jquery-tutorial-for-beginners\/\">&#8220;Introduction to JavaScript with jQuery&#8221;<\/a> lesson ended. We learn how to use variables, conditional logic and functions to create flexible code.<\/p>\n<p><a href=\"https:\/\/learnwebcode.com\/tutorial-files\/jquery-variables-functions\/\">Link to demo page shown in lesson<\/a><\/p>\n<p>Note: The reveal effect shown in this lesson is not terribly useful in real world applications. Most tablets and smartphones cannot run code during the middle of a swipe scroll event so the effect will only run seamlessly on traditional computers \/ laptops. In short, I wouldn&#8217;t necessarily use this effect on a production website, but it is a good playground for the sake of learning more about JavaScript variables, functions, and conditional logic.<\/p>\n<p>Also, I recommend not using jQuery&#8217;s &#8220;animate&#8221; method whenever possible. Instead, you can simply use jQuery to add\/remove a class at the desired moments, and instead use CSS transitions or animations. We&#8217;ll cover this strategy in future lessons. The jQuery animate method is more dependable in older browsers and devices, but the CSS method provides smoother performance.<\/p>\n<p>Finally, we created the &#8220;on scroll reveal&#8221; functionality in this lesson from scratch as a learning exercise. If, however you&#8217;re interested in a more robust and pre-built solution, be sure to search for the existing jQuery plugin named &#8220;jQuery WayPoints.&#8221;<\/p>\n<p class=\"large-text\">Put together a neat page infused with JavaScript awesomeness and want to move it from your computer to online so the world can see your JS chops? The next step is to use a web host to share your site with the world. <a href=\"https:\/\/learnwebcode.com\/web-hosting\/\">Learn about web hosts, my favorite one, and how to get a plan for only $5.78 per month.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This lesson picks up where our original &#8220;Introduction to JavaScript with jQuery&#8221; lesson ended. We learn how to use variables, conditional logic and functions to create flexible code. Link to demo page shown in lesson Note: The reveal effect shown in this lesson is not terribly useful in real world applications. Most tablets and smartphones [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-javascript-video-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>jQuery Variables, Functions, and Conditional Logic - LearnWebCode<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jQuery Variables, Functions, and Conditional Logic - LearnWebCode\" \/>\n<meta property=\"og:description\" content=\"This lesson picks up where our original &#8220;Introduction to JavaScript with jQuery&#8221; lesson ended. We learn how to use variables, conditional logic and functions to create flexible code. Link to demo page shown in lesson Note: The reveal effect shown in this lesson is not terribly useful in real world applications. Most tablets and smartphones [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/\" \/>\n<meta property=\"og:site_name\" content=\"LearnWebCode\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-02T17:07:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-03-15T03:55:52+00:00\" \/>\n<meta name=\"author\" content=\"Brad\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/\"},\"author\":{\"name\":\"Brad\",\"@id\":\"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6\"},\"headline\":\"jQuery Variables, Functions, and Conditional Logic\",\"datePublished\":\"2014-04-02T17:07:54+00:00\",\"dateModified\":\"2016-03-15T03:55:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/\"},\"wordCount\":276,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6\"},\"articleSection\":[\"JavaScript Video Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/\",\"url\":\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/\",\"name\":\"jQuery Variables, Functions, and Conditional Logic - LearnWebCode\",\"isPartOf\":{\"@id\":\"https:\/\/learnwebcode.com\/#website\"},\"datePublished\":\"2014-04-02T17:07:54+00:00\",\"dateModified\":\"2016-03-15T03:55:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learnwebcode.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"jQuery Variables, Functions, and Conditional Logic\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnwebcode.com\/#website\",\"url\":\"https:\/\/learnwebcode.com\/\",\"name\":\"LearnWebCode\",\"description\":\"Become a Web Developer\",\"publisher\":{\"@id\":\"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnwebcode.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6\",\"name\":\"Brad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg\",\"url\":\"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg\",\"contentUrl\":\"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg\",\"width\":400,\"height\":400,\"caption\":\"Brad\"},\"logo\":{\"@id\":\"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg\"},\"url\":\"https:\/\/learnwebcode.com\/author\/lwcadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jQuery Variables, Functions, and Conditional Logic - LearnWebCode","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/","og_locale":"en_US","og_type":"article","og_title":"jQuery Variables, Functions, and Conditional Logic - LearnWebCode","og_description":"This lesson picks up where our original &#8220;Introduction to JavaScript with jQuery&#8221; lesson ended. We learn how to use variables, conditional logic and functions to create flexible code. Link to demo page shown in lesson Note: The reveal effect shown in this lesson is not terribly useful in real world applications. Most tablets and smartphones [&hellip;]","og_url":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/","og_site_name":"LearnWebCode","article_published_time":"2014-04-02T17:07:54+00:00","article_modified_time":"2016-03-15T03:55:52+00:00","author":"Brad","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Brad","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#article","isPartOf":{"@id":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/"},"author":{"name":"Brad","@id":"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6"},"headline":"jQuery Variables, Functions, and Conditional Logic","datePublished":"2014-04-02T17:07:54+00:00","dateModified":"2016-03-15T03:55:52+00:00","mainEntityOfPage":{"@id":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/"},"wordCount":276,"commentCount":1,"publisher":{"@id":"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6"},"articleSection":["JavaScript Video Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/","url":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/","name":"jQuery Variables, Functions, and Conditional Logic - LearnWebCode","isPartOf":{"@id":"https:\/\/learnwebcode.com\/#website"},"datePublished":"2014-04-02T17:07:54+00:00","dateModified":"2016-03-15T03:55:52+00:00","breadcrumb":{"@id":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnwebcode.com\/jquery-variables-functions-and-conditional-logic\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learnwebcode.com\/"},{"@type":"ListItem","position":2,"name":"jQuery Variables, Functions, and Conditional Logic"}]},{"@type":"WebSite","@id":"https:\/\/learnwebcode.com\/#website","url":"https:\/\/learnwebcode.com\/","name":"LearnWebCode","description":"Become a Web Developer","publisher":{"@id":"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnwebcode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/learnwebcode.com\/#\/schema\/person\/db825ebc5a08e39b01de31771e4c7fe6","name":"Brad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg","url":"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg","contentUrl":"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg","width":400,"height":400,"caption":"Brad"},"logo":{"@id":"https:\/\/learnwebcode.com\/wp-content\/uploads\/0UWl0Tet_400x400.jpg"},"url":"https:\/\/learnwebcode.com\/author\/lwcadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":7,"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":917,"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/posts\/186\/revisions\/917"}],"wp:attachment":[{"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnwebcode.com\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}