<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dev Blog Archive - SideCode</title>
	<atom:link href="https://sidecode.io/dev-blog/feed/" rel="self" type="application/rss+xml" />
	<link>https://sidecode.io/dev-blog/</link>
	<description>Web Development &#38; IT Consulting Company</description>
	<lastBuildDate>Thu, 14 May 2020 09:17:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://sidecode.io/wp-content/uploads/logo_icon-150x150.png</url>
	<title>Dev Blog Archive - SideCode</title>
	<link>https://sidecode.io/dev-blog/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Making .gitignore to take effect (gitignore is not working)</title>
		<link>https://sidecode.io/dev-blog/making-gitignore-to-take-effect-gitignore-is-not-working/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Sun, 29 Mar 2020 10:19:37 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1168</guid>

					<description><![CDATA[<p>When you add/modify the .gitignore file and then try to commit the changes, you will see that the files you asked git to ignore are still on the HEAD, they are still there, this is because you need to tell git to remove them from the index. The way to &#8220;fix&#8221; .gitignore file is ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/making-gitignore-to-take-effect-gitignore-is-not-working/">Making .gitignore to take effect (gitignore is not working)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When you add/modify the .gitignore file and then try to commit the changes, you will see that the files you asked git to ignore are still on the HEAD, they are still there, this is because you need to tell git to remove them from the index.</p>
<p>The way to &#8220;fix&#8221; .gitignore file is after making in a .gitignore file, not matter if you working with BitBucket, GitHub, or any other service, to fix the issue you need to execute these commands:</p>
<pre>git rm -rf --cached .
git add . 
git commit -m 'fixed gitignore'</pre>
<p><code>git rm -r --caced</code> &#8211; will remove the files completely from the index (just like add is adding to the index).</p>
<p><code>git add .</code> &#8211; will add all of the files (this is the dot, dot means all).</p>
<p><code>git commit -m 'fixed gitignore'</code> &#8211; will commit the the changes with the label of: &#8220;fixed gitignore&#8221;, this can be whatever you want, for me, each time I start a project and do the first commit, I ALWAYS forget to add/change/create the .gitignore file, so my two first commits are always: &#8216;inital commit&#8217; and &#8216;fixed .gitignore&#8217;.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/making-gitignore-to-take-effect-gitignore-is-not-working/">Making .gitignore to take effect (gitignore is not working)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Installing Composer Globally on CentOS 7</title>
		<link>https://sidecode.io/dev-blog/installing-composer-globally-on-centos-7/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Sun, 03 Sep 2017 10:16:55 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1162</guid>

					<description><![CDATA[<p># Installing Composer Globally on CentOS 7 First you need to make sure your system is up-do-date, for that you need to run yum -y update Download and install Composer by executing the following command: curl -sS https://getcomposer.org/installer &#124; php Once the process completes, you can make the ‘composer.phar’ file executable by running the ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/installing-composer-globally-on-centos-7/">Installing Composer Globally on CentOS 7</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a>Installing Composer Globally on CentOS 7</h3>
<p>First you need to make sure your system is up-do-date, for that you need to run</p>
<pre>yum -y update
</pre>
<p>Download and install Composer by executing the following command:</p>
<pre>curl -sS https://getcomposer.org/installer | php
</pre>
<p>Once the process completes, you can make the ‘composer.phar’ file executable by running the following command:</p>
<pre>chmod +x composer.phar
</pre>
<p>Now use the following commands to make composer available globally for all users in your system, which can be used for all php applications on that system:</p>
<pre>mv composer.phar /usr/local/bin/composer
</pre>
<p>You can also check the version of composer by running bellow command:</p>
<pre>composer -V
</pre>
<p>And you are ready to go.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/installing-composer-globally-on-centos-7/">Installing Composer Globally on CentOS 7</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Block IP Manually from Fail2Ban Plesk server</title>
		<link>https://sidecode.io/dev-blog/block-ip-manually-fail2ban/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Tue, 29 Aug 2017 11:43:04 +0000</pubDate>
				<category><![CDATA[git]]></category>
		<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1138</guid>

					<description><![CDATA[<p>While using Fail2Ban under a Plesk handled server, you have a GUI to view the current Banned IP&#8217;s, and also &#8220;whitelist&#8221; IP&#8217;s (move to trusted IP&#8217;s), But you don&#8217;t have the option to manually add an IP to the Blacklist, and permanently block a specific IP. To do so, SSH to your terminal as ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/block-ip-manually-fail2ban/">Block IP Manually from Fail2Ban Plesk server</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While using Fail2Ban under a Plesk handled server, you have a GUI to view the current Banned IP&#8217;s, and also &#8220;whitelist&#8221; IP&#8217;s (move to trusted IP&#8217;s), But you don&#8217;t have the option to manually add an IP to the Blacklist, and permanently block a specific IP.</p>
<p>To do so, SSH to your terminal as root.</p>
<p>To see all the Fail2Ban Blacklist IP&#8217;s<br />
run (as root):</p>
<pre>sudo iptables -nL</pre>
<p>To manually block an IP</p>
<p>Run:</p>
<pre>sudo fail2ban-client set &lt;JAILNAME&gt; banip &lt;IP ADDRESS&gt;

</pre>
<p>Where:</p>
<p>&lt;JAILNAME&gt; &#8211; Is the Jail name.</p>
<p>&lt;IP ADDRESS&gt; &#8211; Is the ip address you want to ban.</p>
<p>&nbsp;</p>
<p>To see your Jail&#8217;s run:</p>
<pre>fail2ban-client status</pre>
<p>To see the list of Banned IP&#8217;s Run:</p>
<pre>iptables -L -n</pre>
<p>In Plesk the common Jail to use is &#8220;recidive&#8221;</p>
<p>So the command will look like:</p>
<pre>sudo fail2ban-client set recidive banip &lt;IP_ADDRESS&gt;</pre>
<p>Be careful not to ban your own IP 🙂</p>
<p>If you do, just switch to your phone network (open an HotSpot) and whitelist your IP (add to Trusted IP&#8217;s).</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/block-ip-manually-fail2ban/">Block IP Manually from Fail2Ban Plesk server</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Bitbucket &#8211; Setup Git on a Remote Server For an existing Repo</title>
		<link>https://sidecode.io/dev-blog/bitbucket-setup-git-on-a-remote-server-for-an-existing-repo/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Wed, 12 Apr 2017 09:59:03 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1146</guid>

					<description><![CDATA[<p>Step 1: Switch to your repository&#8217;s directory cd /path/to/your/repo Step 2: Connect your existing repository to Bitbucket git remote add origin https://PATH_TO_YOUR_REPO git push -u origin master</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/bitbucket-setup-git-on-a-remote-server-for-an-existing-repo/">Bitbucket &#8211; Setup Git on a Remote Server For an existing Repo</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Step 1: Switch to your repository&#8217;s directory</p>
<pre>cd /path/to/your/repo
</pre>
<p>Step 2: Connect your existing repository to Bitbucket</p>
<pre>git remote add origin https://PATH_TO_YOUR_REPO</pre>
<pre>git push -u origin master</pre>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/bitbucket-setup-git-on-a-remote-server-for-an-existing-repo/">Bitbucket &#8211; Setup Git on a Remote Server For an existing Repo</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Setting Git on a Production Server</title>
		<link>https://sidecode.io/dev-blog/setting-git-on-a-production-server/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Sat, 25 Mar 2017 09:57:42 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1145</guid>

					<description><![CDATA[<p>To set your git repo on your production server. go tho the root directory of the server (i.e. public_html or httpdocs etc.) then run: git init run (to connect your server with the cloud repo) git remote add origin https://PATH_TO_YOUR_REPO Then if you want your production server to always pull from the remote origin ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/setting-git-on-a-production-server/">Setting Git on a Production Server</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>To set your git repo on your production server.<br />
go tho the root directory of the server (i.e. public_html or httpdocs etc.)<br />
then run:</p>
<pre>git init</pre>
<p>run (to connect your server with the cloud repo)</p>
<pre>git remote add origin https://PATH_TO_YOUR_REPO
</pre>
<p>Then if you want your production server to always pull from the remote origin (so you will be able to run git pull instead of git pull origin master)<br />
You need to add this to your /.git/cofig, you can do this like this:</p>
<pre> git config branch.master.remote origin
 git config branch.master.merge refs/heads/master
</pre>
<p>Now you can run git pull, and it will automatically pull from your master branch.</p>
<p>&nbsp;</p>
<p>If you also git to remember your password (so you won&#8217;t need to type it with every &#8220;git pull&#8221;)</p>
<p>enable credentials cache: (make sure you have git version &gt; 1.7.12.1, which you probably have).</p>
<pre class="prettyprint prettyprinted"><span class="pln">git config </span><span class="pun">--</span><span class="kwd">global</span><span class="pln"> credential</span><span class="pun">.</span><span class="pln">helper cache</span></pre>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/setting-git-on-a-production-server/">Setting Git on a Production Server</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Git Error &#8211; invalid active developer path (also called, did you upgraded to macOS Sierra?)</title>
		<link>https://sidecode.io/dev-blog/git-error-invalid-active-developer-path-also-called-did-you-upgraded-to-macos-sierra/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Wed, 01 Feb 2017 09:59:58 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1148</guid>

					<description><![CDATA[<p>If you are getting this error,  error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun This is because you are on a Mac, and you upgraded to macOS Sierra. To fix this, all you need to do is update/install Xcode. run this command in the terminal: &#160; xcode-select --install Run the command, agree ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/git-error-invalid-active-developer-path-also-called-did-you-upgraded-to-macos-sierra/">Git Error &#8211; invalid active developer path (also called, did you upgraded to macOS Sierra?)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you are getting this error,  error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun</p>
<p>This is because you are on a Mac, and you upgraded to macOS Sierra.</p>
<p>To fix this, all you need to do is update/install Xcode.<br />
run this command in the terminal:</p>
<p>&nbsp;</p>
<pre>xcode-select --install</pre>
<p>Run the command, agree to the agreement and install Xcode.<br />
This will fix the issue.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/git-error-invalid-active-developer-path-also-called-did-you-upgraded-to-macos-sierra/">Git Error &#8211; invalid active developer path (also called, did you upgraded to macOS Sierra?)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress &#8211; Change User Role Name</title>
		<link>https://sidecode.io/dev-blog/wordpress-change-user-role-name/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Mon, 05 Dec 2016 10:02:28 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1154</guid>

					<description><![CDATA[<p># WordPress &#8211; Change User Role name in functions.php : function change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); //You can list all currently available roles like this… // This is only for you to see whats going on, after checking, remove these 2 lines altogether $roles ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-change-user-role-name/">WordPress &#8211; Change User Role Name</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a>WordPress &#8211; Change User Role name</h3>
<p>in functions.php :</p>
<pre>function change_role_name() {
    global $wp_roles;

    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles();

    //You can list all currently available roles like this…
    // This is only for you to see whats going on, after checking, remove these 2 lines altogether 
    $roles = $wp_roles-&gt;get_names();
    print_r($roles);

    //You can replace "administrator" with any other role "editor", "author", "contributor" or "subscriber"...
    $wp_roles-&gt;roles['administrator']['name'] = 'god';
    $wp_roles-&gt;role_names['administrator'] = 'god';           
}
add_action('init', 'change_role_name');
</pre>
<p>That&#8217;s about it, all you need to do to change user role.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-change-user-role-name/">WordPress &#8211; Change User Role Name</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress &#8211; Creating a Child Theme, The Pure Basics</title>
		<link>https://sidecode.io/dev-blog/wordpress-creating-a-child-theme-the-pure-basics/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Mon, 14 Nov 2016 10:04:13 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1156</guid>

					<description><![CDATA[<p># WordPress &#8211; Creating a Child Theme, the pure basics A child theme consists of at least one directory (the child theme directory) that will be placed under the themes folder and two files (style.css and functions.php), which you will need to create: This is basically all you need to create a child theme. ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-creating-a-child-theme-the-pure-basics/">WordPress &#8211; Creating a Child Theme, The Pure Basics</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="#"># </a>WordPress &#8211; Creating a Child Theme, the pure basics</h3>
<p>A child theme consists of at least one directory (the child theme directory) that will be placed under the themes folder and two files (style.css and functions.php), which you will need to create:</p>
<p>This is basically all you need to create a child theme.</p>
<p>name the folder : themename-child<br />
style.css &#8211; header:</p>
<pre>/*
 Theme Name:   My Child
 Theme URI:    http://example.com/
 Description:  My Child Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     myChild
 Version:      1.0.0
 Text Domain:  my-child-child
*/ 
</pre>
<p>functions.php:</p>
<pre> // Opening PHP tag - nothing should be before this, not even whitespace

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}

</pre>
<p>Note: Check their is no trailing space after this close php tag (<code>?&gt;</code>).</p>
<p>Now the thumb rule is that if you want to override a file in the pedant theme all you need to do is to create it with the exact same name in your child theme, or create new files with new functionality to extend the parent theme.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-creating-a-child-theme-the-pure-basics/">WordPress &#8211; Creating a Child Theme, The Pure Basics</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>JavaScript &#8211;  Getting URL Parameter and setting a URL parameter  (Snippet)</title>
		<link>https://sidecode.io/dev-blog/javascript-getting-url-parameter-and-setting-a-url-parameter-snippet/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Tue, 08 Nov 2016 10:15:44 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1160</guid>

					<description><![CDATA[<p># Getting a URL Parameter A function that you give it the param, (url params or url args, whatever you want to call it) to find from the current url (key), and she returns the value of that parameter. var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&#38;'), sParameterName, i; ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/javascript-getting-url-parameter-and-setting-a-url-parameter-snippet/">JavaScript &#8211;  Getting URL Parameter and setting a URL parameter  (Snippet)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a>Getting a URL Parameter</h3>
<p>A function that you give it the param, (url params or url args, whatever you want to call it) to find from the current url (key), and she returns the value of that parameter.</p>
<pre>var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&amp;'),
        sParameterName,
        i;

    for (i = 0; i &lt; sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
};

  var area = getUrlParameter(‘area'); // get area value.
  if (typeof area == 'undefined') {
    // do something it exists!
  } else {
    // cry me a river
  }
</pre>
<h3><a href="“#”"># </a>Setting a URL Parameter (or changing it)</h3>
<p>Sometimes it is handy to change (or add ) a url parameter, from JavaScript</p>
<p>This function that you give it a : key (kuku) and a value (..value) and she updates the appropriate key, if dosen’t exists, she creates it.<br />
the function doesn’t touch other parameters (leave them like they were).</p>
<p>I used it in a situation where it was needed to check a parameter called “killme”<br />
if killme value was given to the function, she will delete the appropriate value.<br />
note: if killme sent when their is no such parameter, she creates it with this value.</p>
<pre>// added 'killme' value - to remove the query var alltogether. 
function setGetParameter(paramName, paramValue)
{
    var url = window.location.href;
    if (url.indexOf(paramName + "=") &gt;= 0)
    {
        var prefix = url.substring(0, url.indexOf(paramName));
        var suffix = url.substring(url.indexOf(paramName));
        suffix = suffix.substring(suffix.indexOf("=") + 1);
        suffix = (suffix.indexOf("&amp;") &gt;= 0) ? suffix.substring(suffix.indexOf("&amp;")) : "";
        if (paramValue == 'killme') {
        url = prefix + suffix;
        }
        else {
        url = prefix + paramName + "=" + paramValue + suffix;
        }
    }
    else
    {
    if (url.indexOf("?") &lt; 0)
        url += "?" + paramName + "=" + paramValue;
    else
        url += "&amp;" + paramName + "=" + paramValue;
    }
    window.location.href = url;
}
</pre>
<p>usage :</p>
<pre>  // Handles click
  jQuery( ‘.page-templat-page-something.area-widget li a' ).click(function( event ) {
    event.preventDefault(); 
   var href = jQuery(this).attr(‘href'); //get the a href
    if (typeof location != 'undefined' || href !='killme') { // check if location exists and if the value is not kill
	// .. killme request (because if kill and doesn’t exists -&gt;when try to kill error, this fix that)
      setGetParameter('area',href);
    }
});
</pre>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/javascript-getting-url-parameter-and-setting-a-url-parameter-snippet/">JavaScript &#8211;  Getting URL Parameter and setting a URL parameter  (Snippet)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>jQuery and General JavaScript Snippets</title>
		<link>https://sidecode.io/dev-blog/jquery-and-general-javascript-snippets/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Tue, 08 Nov 2016 10:05:08 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1157</guid>

					<description><![CDATA[<p>This will be a growing list of jQury, maybe even general JavaScript Snippets that I use a lot and always forget. # Add/Remove a class jQuery Add a class to a element jQuery(‘selector’).addClass(‘active’); Remove class from an element $( "p" ).removeClass( "myClass yourClass" ) # Find the html &#60;a&#62; Element with href that contain a ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/jquery-and-general-javascript-snippets/">jQuery and General JavaScript Snippets</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This will be a growing list of jQury, maybe even general JavaScript Snippets that I use a lot and always forget.</p>
<h3><a href="#"># </a>Add/Remove a class jQuery</h3>
<p>Add a class to a element</p>
<pre>jQuery(‘selector’).addClass(‘active’);</pre>
<pre>Remove class from an element</pre>
<pre>$( "p" ).removeClass( "myClass yourClass" )
</pre>
<h3><a href="“#”"># </a>Find the html <code>&lt;a&gt;</code> Element with href that contain a certain string</h3>
<p>Sometimes you need to find in your web page a anchor element with a specific string in it’s href<br />
this is example of find the a tag with href that contains “vc” var and adds a class to it’s<br />
parent element.</p>
<pre>jQuery('#menu-vendor-team-categories a[href*=“'+vc+'"]').parent().addClass('active');
</pre>
<p>Some of the selector stuff you can use, based on your needs:<br />
Selector documentation can be found at:</p>
<p>For Example:<br />
<code>=</code> &#8211; find a string that is exactly equal.<br />
<code>!=</code> &#8211; find a string that is not equal.<br />
<code>^=</code> &#8211; find a string that starts with.<br />
<code>$=</code> &#8211; find a string that ends with.<br />
<code>*=</code> &#8211; find a string that contains.<br />
<code>~=</code> &#8211; find a strings that contain this word.<br />
<code>|=</code> &#8211; find a string that starts with a prefix (<code>|=</code> “prefix” matches “prefix-…”).</p>
<h3><a href="#"># </a>Prevent Default</h3>
<p>General Javascript snippet.<br />
Stop the normal behavior of this element click event and do what i want.<br />
Can be applied with .on click &#8211; so that on click it will prevent default behavior and do as you please</p>
<pre> jQuery( ‘.#myElement' ).click(function( event ) {
    event.preventDefault();
    // do as you please here !
    }
});
</pre>
<h3><a href="“#”"># </a>Get Href of element (Guess it’s good for getting more things)</h3>
<p>href now contains the href string of this element. (if you got stupid or something):</p>
<pre>    
var href = jQuery(this).attr('href');
</pre>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/jquery-and-general-javascript-snippets/">jQuery and General JavaScript Snippets</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Object Caching 0/248 objects using disk
Page Caching using disk: enhanced 
Database Caching 3/84 queries in 0.172 seconds using disk

Served from: sidecode.io @ 2026-05-14 08:23:44 by W3 Total Cache
-->