<?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: Anand Raj</title>
    <description>The latest articles on DEV Community by Anand Raj (@anand346).</description>
    <link>https://dev.to/anand346</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%2F830628%2Ff9591c63-ab7a-4ff2-9c4f-9d23e1246644.jpg</url>
      <title>DEV Community: Anand Raj</title>
      <link>https://dev.to/anand346</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anand346"/>
    <language>en</language>
    <item>
      <title>Where does css placed in html : 3 places for css</title>
      <dc:creator>Anand Raj</dc:creator>
      <pubDate>Thu, 28 Jul 2022 03:30:01 +0000</pubDate>
      <link>https://dev.to/anand346/where-does-css-placed-in-html-3-places-for-css-37m3</link>
      <guid>https://dev.to/anand346/where-does-css-placed-in-html-3-places-for-css-37m3</guid>
      <description>&lt;p&gt;Article is originally published @ &lt;a href="https://bepractical.tech/where-does-css-placed-in-html-3-places-for-css/"&gt;bepractical&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hey developers , in this article I am going to show you where does css can be placed inside your html file .&lt;/p&gt;

&lt;p&gt;So let’s get started : )&lt;br&gt;
Method to place css in html file&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;External css&lt;/li&gt;
&lt;li&gt;Internal css&lt;/li&gt;
&lt;li&gt;Inline css&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  External css
&lt;/h2&gt;

&lt;p&gt;In this method , you have to write css in an external file and then link that css file in html file .&lt;/p&gt;

&lt;p&gt;Let’s assume that you have made an &lt;code&gt;style.css&lt;/code&gt; file in your html file directory , and wrote some css code in it . Then in html file you can link the css file like below example&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;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
&amp;lt;title&amp;gt;My Home Page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;h1&amp;gt;Welcome to Homepage !&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;Greetings :)&amp;lt;/p&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;link /&amp;gt;&lt;/code&gt; tag is used to link css files in html file . Attribute href is used to give location of css file .&lt;/p&gt;

&lt;p&gt;Your style.css does not contain any html tags and file will look something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#banner{
  background-color: lightblue;
}

#banner p{
  color: navy;
  margin-left: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s move toward the second method i.e., Internal css&lt;/p&gt;

&lt;h2&gt;
  
  
  Internal css
&lt;/h2&gt;

&lt;p&gt;This is the second method to place css in html file . In this method there is no need to make an external file for css and link it to the html file .&lt;/p&gt;

&lt;p&gt;In this method css is placed inside the html file inside &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag of &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag like the below code .&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;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;style&amp;gt;
#banner{
  background-color: lightblue;
}

#banner p{
  color: navy;
  margin-left: 20px;
}
&amp;lt;/style&amp;gt;
&amp;lt;title&amp;gt;My Home Page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;h1&amp;gt;Welcome to Homepage !&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;Greetings :)&amp;lt;/p&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Inline css
&lt;/h2&gt;

&lt;p&gt;In this method all the css is applied in the style attribute of that tag like the example below . Style attriubte can contain any number of css properties .&lt;/p&gt;

&lt;p&gt;Read full article here 👉 &lt;a href="https://bepractical.tech/where-does-css-placed-in-html-3-places-for-css/"&gt;https://bepractical.tech/where-does-css-placed-in-html-3-places-for-css/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to check battery status with javascript ( 2 simple steps )</title>
      <dc:creator>Anand Raj</dc:creator>
      <pubDate>Sun, 24 Jul 2022 01:45:00 +0000</pubDate>
      <link>https://dev.to/anand346/how-to-check-battery-status-with-javascript-2-simple-steps--j52</link>
      <guid>https://dev.to/anand346/how-to-check-battery-status-with-javascript-2-simple-steps--j52</guid>
      <description>&lt;p&gt;In this tutorial I am going to show you how easily you can &lt;strong&gt;check battery status of system using javascript&lt;/strong&gt; battery API .&lt;/p&gt;

&lt;p&gt;Using the battery API various information about the system battery can be extracted , thus increasing the user experience also , in case user needs urgent charging .&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting battery Information
&lt;/h2&gt;

&lt;p&gt;The battery API is not working in all browser , so first of all before getting the battery status we need to check that if browser supports the battery API or not .&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking API working in browser
&lt;/h2&gt;

&lt;p&gt;Now to check the working of API in browser we need to use &lt;code&gt;getBattery&lt;/code&gt; method on navigator API , as shown in the example below .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(navigator.getBattery){
    // if battery API is working
}
else{
    // if battery API is not working
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Check battery status
&lt;/h2&gt;

&lt;p&gt;If the battery API is working then we can check the battery percentage with &lt;code&gt;getBattery()&lt;/code&gt; API , this API returns a &lt;a href="https://bepractical.tech/how-to-use-promise-in-javascript-read-this-definitive-guide/"&gt;promise &lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;navigator.getBattery()
    .then(function(battery) {

        // Get current battery level .
        var batteryLevel = battery.level * 100;
        console.log(batteryLevel);
    })
    .catch(function(e) {
        console.error(e);
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;battery&lt;/code&gt; object has the following properties we can use to extract more information about sytem battery .&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;battery.level&lt;/code&gt; : to check the battery level &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;battery.charging&lt;/code&gt; : to check if the battery is currently charging or not (true/false)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;battery.chargingTime&lt;/code&gt; : to check the time remaining in full charge of battery &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;battery.dischargingTime&lt;/code&gt; : to check the time remaining in battery dead .&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now to detect changes in all these properties at real time javascript provide us some event listeners , as shown below .&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;battery.onlevelchange&lt;/code&gt; : to detect change in battery level &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;battery.onchargingchange&lt;/code&gt; : to detect change in power plug in/out of battery &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;battery.onchargingtimechange&lt;/code&gt; : to detect change in battery level &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;battery.onlevelchange&lt;/code&gt; : to detect change in battery level &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the below example as soon as the battery level goes below 15% an alert will popup recommending connecting system to charger .&lt;/p&gt;

&lt;p&gt;Read full article here 👉 &lt;a href="https://bepractical.tech/how-to-check-battery-status-with-javascript-2-simple-steps/"&gt;https://bepractical.tech/how-to-check-battery-status-with-javascript-2-simple-steps/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to upload file with ajax jquery : Simplest method</title>
      <dc:creator>Anand Raj</dc:creator>
      <pubDate>Fri, 22 Jul 2022 08:06:04 +0000</pubDate>
      <link>https://dev.to/anand346/how-to-upload-file-with-ajax-jquery-simplest-method-25cl</link>
      <guid>https://dev.to/anand346/how-to-upload-file-with-ajax-jquery-simplest-method-25cl</guid>
      <description>&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UN5bVBbi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6koqnwa5rwspifysrx1r.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UN5bVBbi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6koqnwa5rwspifysrx1r.gif" alt="upload image with ajax jquery - bepractical.tech" width="600" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hey developers , in this tutorial you will learn how to upload file using AJAX Jquery . Basically ajax is a method to send request in backend with reloading the whole page .&lt;/p&gt;

&lt;p&gt;Storing an image file in backend requires an file input in html , some styling with css and if you want some animations you can use Javascript .&lt;/p&gt;

&lt;p&gt;Jquery is a javascript library , it is mainly used for DOM and ajax is a jquery method used to send request in backend . In javascript ajax is known as xmlHttpRequest .&lt;/p&gt;

&lt;h2&gt;
  
  
  Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;jquery&lt;/li&gt;
&lt;li&gt;PHP&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  HTML File
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta charset="UTF-8"&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&amp;lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&amp;gt;
&amp;lt;meta name="Description" content="Enter your description here"/&amp;gt;
&amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css"&amp;gt;
&amp;lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"&amp;gt;
&amp;lt;title&amp;gt;Upload file&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;div class="container"&amp;gt;
        &amp;lt;div class="row d-flex justify-content-center align-items-center" &amp;gt;
            &amp;lt;div class="col-md-6 my-5 d-flex justify-content-start align-items-center flex-column" &amp;gt;
                &amp;lt;img src="" alt="" class = "mb-3 show_image" /&amp;gt;
                &amp;lt;div class="file_upload"&amp;gt;
                    &amp;lt;input type="file" name="file" id="fileInput"&amp;gt;
                    &amp;lt;button class = "uploadButton" &amp;gt;Upload&amp;lt;/button&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code block &lt;code&gt;img&lt;/code&gt; tag is used to show the uploaded image file , and  tag is used to choose for image file to be uploaded .&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS File
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.row{
    width:100%;
}
.col-md-6{
    width:500px;
    height:300px;
    border-radius: 10px;
    overflow: hidden;
}
img{
    width:95%;
    height:80%;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Write the above code in a seprate css file and link it with the html file .&lt;/p&gt;

&lt;h2&gt;
  
  
  Jquery code
&lt;/h2&gt;

&lt;p&gt;Before writing jquey code , include jquery’s cdn link into your html file&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;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then after write the below jquery code in &lt;code&gt;script&lt;/code&gt; tag below jquery linkage into your html file.&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(){

        $(".uploadButton").click(function(){

            var fd = new FormData();
            var files = $('#fileInput')[0].files;
            // console.log(files);
            // Check file selected or not
            if(files.length &amp;gt; 0 ){
                fd.append('file',files[0]);

                $.ajax({
                    url: 'upload.php',
                    type: 'post',
                    data: fd,
                    success: function(response){
                        if(response){
                            $(".show_img").attr("src",response); 
                        }else{
                            console.log('file not uploaded');
                        }
                    },
                });
            }else{
                alert("Please select a file.");
            }
        });
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above jquery code we have used &lt;code&gt;FormData()&lt;/code&gt; to upload file in backend . After successful uploading of file we are showing it into image tag .&lt;/p&gt;

&lt;p&gt;Read Full Article here 👉 &lt;a href="https://bepractical.tech/how-to-upload-file-with-ajax-jquery-simplest-method/"&gt;https://bepractical.tech/how-to-upload-file-with-ajax-jquery-simplest-method/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Easiest way to connect database in javascript (3 simple steps)</title>
      <dc:creator>Anand Raj</dc:creator>
      <pubDate>Mon, 18 Jul 2022 02:06:06 +0000</pubDate>
      <link>https://dev.to/anand346/easiest-way-to-connect-database-in-javascript-3-simple-steps-2abf</link>
      <guid>https://dev.to/anand346/easiest-way-to-connect-database-in-javascript-3-simple-steps-2abf</guid>
      <description>&lt;p&gt;Javascript is one of the most popular programming languages , as all other languages like PHP , C# , Python they all provides driver to connect with Mysql Server . And unlike the MongoDB database Mysql also provides it’s module for Nodejs to connect with , as Mysql is also a popular relational database so there’s need to be support for Nodejs .&lt;/p&gt;

&lt;p&gt;Mysql’s module &lt;a href="https://www.npmjs.com/package/mysql"&gt;mysql &lt;/a&gt;i.e., driver for Nodejs helps Nodejs developer to connect with Mysql server , it’s a very easy library to use and implement .&lt;/p&gt;

&lt;p&gt;In this article you will learn to connect with Mysql database using Javascript Nodejs in 3 simple steps .&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;We need the below two requirements in order to make connection with Mysql database using Javascript Nodejs .&lt;/p&gt;

&lt;p&gt;1 . Mysql Server (we are using XAMPP )&lt;/p&gt;

&lt;p&gt;2 . Nodejs installed &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 : Install Mysql Nodejs library
&lt;/h2&gt;

&lt;p&gt;To install the mysql library you need to have Nodejs installed in your system . Run the following command to install mysql library .&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install mysql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After installation you need to require this module in your main file before making connection to database .&lt;/p&gt;

&lt;p&gt;Note : Don’t forgot to start Mysql server before making a connection unless you will face an error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 : Make connection to database and execute queries
&lt;/h2&gt;

&lt;p&gt;After successful installation of library you can make connection to database . You can make connection to database in 2 ways&lt;/p&gt;

&lt;p&gt;1 . Simple connection&lt;/p&gt;

&lt;p&gt;2 . Pooled connection&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple connection
&lt;/h2&gt;

&lt;p&gt;In simple connection you will use the basic components to make a connection to Mysql database . First of all you need to require the mysql library in file and then with createConnection() pass all the required parameters i.e., host , user , password , database as shown in below example .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var mysql = require('mysql'); // requiring nodejs mysql library

var connection = mysql.createConnection({ // creating database connection
    host     : 'localhost',
    user     : 'root',
    password : '',
    database : 'users_db'
})

 // You can refer to this article originally published at
 // https://bepractical.tech/easiest-way-to-connect-database-in-javascript-3-simple-steps/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Article link&lt;/strong&gt; : &lt;a href="https://bepractical.tech/easiest-way-to-connect-database-in-javascript-3-simple-steps/"&gt;https://bepractical.tech/easiest-way-to-connect-database-in-javascript-3-simple-steps/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>node</category>
      <category>database</category>
    </item>
    <item>
      <title>This is my first post at dev.to . I am a full stack web developer (php) .</title>
      <dc:creator>Anand Raj</dc:creator>
      <pubDate>Tue, 15 Mar 2022 02:10:54 +0000</pubDate>
      <link>https://dev.to/anand346/this-is-my-first-post-at-devto-i-am-a-full-stack-web-developer-php--4mh</link>
      <guid>https://dev.to/anand346/this-is-my-first-post-at-devto-i-am-a-full-stack-web-developer-php--4mh</guid>
      <description></description>
      <category>php</category>
      <category>javascript</category>
      <category>mysql</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
