<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Javascript on traviscj/blog</title>
    <link>https://traviscj.com/blog/tags/javascript/</link>
    <description>Recent content in Javascript on traviscj/blog</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 23 Oct 2018 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://traviscj.com/blog/tags/javascript/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>moar stupid jquery tricks</title>
      <link>https://traviscj.com/blog/post/2018-10-23-moar_stupid_jquery_tricks/</link>
      <pubDate>Tue, 23 Oct 2018 00:00:00 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-10-23-moar_stupid_jquery_tricks/</guid>
      <description>&lt;p&gt;Sometimes it&amp;rsquo;s useful to use &lt;a href=&#34;https://tampermonkey.net/&#34;&gt;tampermonkey&lt;/a&gt; on a site without nice &lt;code&gt;id&lt;/code&gt;s for the elements you want to edit.&#xA;It turns out it&amp;rsquo;s still pretty easy!&lt;/p&gt;&#xA;&lt;p&gt;Take &lt;a href=&#34;https://traviscj.com/&#34;&gt;my own website&lt;/a&gt;; I have &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; elements for the headers, but none of them have any &lt;code&gt;id&lt;/code&gt;s associated.&#xA;But as discussed in the &lt;a href=&#34;https://traviscj.com/blog/post/2018-10-17-jquery_selectors/&#34;&gt;jquery selectors&lt;/a&gt; post, we can still select by just the tag, with a selector like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;$(&amp;quot;h2&amp;quot;)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This returns a &lt;code&gt;jQuery&lt;/code&gt; object, which behaves like an array.&#xA;If we want to select a particular one &amp;ndash; like &amp;ldquo;Research Interests&amp;rdquo; &amp;ndash; we can try accessing different elements until we get the one we want:&lt;/p&gt;</description>
    </item>
    <item>
      <title>killing all timeouts in js</title>
      <link>https://traviscj.com/blog/post/2018-10-17-killing_all_timeouts_in_js/</link>
      <pubDate>Wed, 17 Oct 2018 20:43:04 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-10-17-killing_all_timeouts_in_js/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://activelab.io/code-snippets/clearing-all-javascript-timeouts&#34;&gt;this article&lt;/a&gt; has a nice trick for killing all javascript timeouts:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;function stopAllTimeouts() {&#xA;    var id = window.setTimeout(null, 0);&#xA;    while (id--) {&#xA;        window.clearTimeout(id);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which can be entered on the javascript console and then run with&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;stopAllTimeouts()&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is an effective way to prevent javascript timeouts from doing a whole variety of things, like&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;carousels&lt;/li&gt;&#xA;&lt;li&gt;endless scrolls&lt;/li&gt;&#xA;&lt;li&gt;any other kind of animations&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>jquery selectors</title>
      <link>https://traviscj.com/blog/post/2018-10-17-jquery_selectors/</link>
      <pubDate>Wed, 17 Oct 2018 03:51:27 +0000</pubDate>
      <guid>https://traviscj.com/blog/post/2018-10-17-jquery_selectors/</guid>
      <description>&lt;p&gt;This is silly, but I always forget this:&lt;/p&gt;&#xA;&lt;!-- raw HTML omitted --&gt;&#xA;&lt;p&gt;I also learned you can specify things like&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// @require https://code.jquery.com/jquery-2.1.4.min.js&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;in a Tampermonkey script, even when a given site doesn&amp;rsquo;t already have jquery.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
