Javascript

jQuery Data vs Attr?

<p>What is the difference in usage between <span class="inlinecode">$.data</span> and <span class="inlinecode">$.attr</span> when using <span class="inlinecode">data-someAttribute</span> ?</p> <p>My understanding is that <span class="inlinecode">

.prop() vs .attr()

<p>So <a href="http://api.jquery.com/category/version/1.6/" rel="noreferrer">jQuery 1.6</a> has the new function <a href="http://api.jquery.com/prop/" rel="noreferrer"><span class="inlinecode">prop()</span> </a> .</p> <pre><code>$(selector).click(fu

Check if object is array?

<p>I&rsquo;m trying to write a function that either accepts a list of strings, or a single string. If it&rsquo;s a string, then I want to convert it to an array with just the one item. Then I can loop over it without fear of an error.</p> <p>So how

Strip HTML from Text JavaScript

<p>Is there an easy way to take a string of html in JavaScript and strip out the html?</p> <p><br><br><br><h1>Answer</h1> If you&rsquo;re running in a browser, then the easiest way is just to <a href="http://jsfiddle.net/8JSZX/" rel="noreferrer">let

Add days to JavaScript Date

<p>How to add days to current <span class="inlinecode">Date</span> using JavaScript. Does JavaScript have a built in function like .Net&rsquo;s <span class="inlinecode">AddDay</span> ?</p> <p><br><br><br><h1>Answer</h1> You can create one with:-</

Encode URL in JavaScript?

<p>How do you safely encode a URL using JavaScript such that it can be put into a GET string?</p> <pre><code>var myUrl = &amp;#34;http://example.com/index.html?param=1&amp;amp;anotherParam=2&amp;#34;; var myOtherUrl = &amp;#34;http://example.com/ind