<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gaurav Tiwari</title>
    <description>The latest articles on DEV Community by Gaurav Tiwari (@wpgaurav).</description>
    <link>https://dev.to/wpgaurav</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F378518%2Fe839ac0d-20de-4c68-af35-e3abfe00638a.jpeg</url>
      <title>DEV Community: Gaurav Tiwari</title>
      <link>https://dev.to/wpgaurav</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wpgaurav"/>
    <language>en</language>
    <item>
      <title>Neat and Easy to Use jQuery Examples</title>
      <dc:creator>Gaurav Tiwari</dc:creator>
      <pubDate>Thu, 16 Jul 2020 19:46:34 +0000</pubDate>
      <link>https://dev.to/wpgaurav/neat-and-easy-to-use-jquery-examples-52bc</link>
      <guid>https://dev.to/wpgaurav/neat-and-easy-to-use-jquery-examples-52bc</guid>
      <description>&lt;p&gt;jQuery is the most popular JavaScript library in use today. It gives web developers a great relief  by abstracting away the complex tasks of traversing the DOM, creating elements, handling events and much more. Many people search for some amazing and simple jQuery tutorials on the web. Here I will show you some simple jQuery tutorial which helps you a lot.&lt;/p&gt;

&lt;h2&gt;
  
  
  1)Disable right click option (jQuery tutorial)
&lt;/h2&gt;

&lt;p&gt;If you want to disable the right click option (context menu) on a webpage in your browser then you can use this small jquery trick.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$(document).ready(function(){
$(document).on(“contextmenu”,function(e){ e.preventDefault(); });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above listens for contextmenu event, and calls the &lt;code&gt;preventDefault()&lt;/code&gt; method.&lt;/p&gt;

&lt;h2&gt;
  
  
  2)Define an &lt;code&gt;exists&lt;/code&gt; function  (jQuery tutorial)
&lt;/h2&gt;

&lt;p&gt;If you want to check, if element exists or not then you can use this small jquery trick also.&lt;br&gt;
There are two ways to check if element exists:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//old way :
console.log($(‘#element’).length == 1 ? “exists!” : “doesn’t exist!”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//new trick:
jQuery.fn.exists = function(){ return this.length &amp;gt; 0; }
console.log($(‘#element’).exists() ? “exists!” : “doesn’t exist!”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In both tricks you can use length property and a ternary conditional statement. But the second way is more useful than the first because you can  extend jQuery with your own functions and you can use &lt;code&gt;exists()&lt;/code&gt; function normally as you can use other functions in jQuery.&lt;/p&gt;

&lt;h2&gt;
  
  
  3)Find external links and Mark them (jQuery tutorial)
&lt;/h2&gt;

&lt;p&gt;In this example, I will show you how to mark external links with text “external link” using jquery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul id=”Links”&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href=”index.html”&amp;gt;Home&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href=”./cat.html”&amp;gt;Category&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;!– External Link: –&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href=”http://www.google.com/”&amp;gt;Google&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;jQuery&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$(document).ready(function(){
// Loop through all the links
$(‘#Links a’).each(function(){
if(this.hostname != location.hostname){
// The link is external
$(this).append(‘&amp;lt;span&amp;gt; – (External Link)&amp;lt;/span&amp;gt;’).attr(‘target’,’_blank’); }
});
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above will loop through all the links and checks if the link’s hostname is equal to the website’s hostname, if the hostname of link is not equal to the hostname of the website. Then the link is marked as an external link.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>jquery</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Working with Date and Time Functions in PHP5 and PHP7</title>
      <dc:creator>Gaurav Tiwari</dc:creator>
      <pubDate>Thu, 16 Jul 2020 14:45:11 +0000</pubDate>
      <link>https://dev.to/wpgaurav/working-with-date-and-time-functions-in-php5-and-php7-3lnp</link>
      <guid>https://dev.to/wpgaurav/working-with-date-and-time-functions-in-php5-and-php7-3lnp</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--shL2XPtT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/gauravtiwari.org/wp-content/uploads/2020/07/date-and-time-functions-in-php-1.png%3Ffit%3D1600%252C800%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--shL2XPtT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/gauravtiwari.org/wp-content/uploads/2020/07/date-and-time-functions-in-php-1.png%3Ffit%3D1600%252C800%26ssl%3D1" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Working with date and time functions is very common in PHP. Date and time functions help you to get the current date and time from the server and also enables you to format&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Working with Date and Time Functions in PHP5 and PHP7](&lt;a href="https://gauravtiwari.org/date-and-time-functions-in-php/"&gt;https://gauravtiwari.org/date-and-time-functions-in-php/&lt;/a&gt;) was originally published at &lt;a href="https://gauravtiwari.org"&gt;Gaurav Tiwari -&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programmingstuff</category>
      <category>php</category>
    </item>
  </channel>
</rss>
