Wednesday, 1 August 2018

                                                               jQuery Selectors

=======================================================================================================================================
Selecting an element by ID in jQuery
Selecting elements by class name in jQuery
Selecting elements by element name in jQuery
Selecting elements by attribute in jQuery
Selecting elements by compound CSS selector in jQuery
Selecting elements by jQuery custom selector
===========================================================================================================================================
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Select Element by ID</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    // Highlight element with id mark
    $("#mark").css("background", "blue");
});
</script>
</head>
<body>
    <p id="mark">Govind Ballabh Khan.</p>
    <p>My name is khan.</p>
    <p>Khan is my title but i am maithil brahmin</p>
    <p><strong>Note:</strong> The value of the id attribute must be unique in an HTML document.</p>
</body>
</html>                           


=========================================================================================================================================

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Select Element by Class</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    // Highlight elements with class mark
    $(".mark").css("background", "yellow");
});
</script>
</head>
<body>
     <p class="mark">Govind Ballabh Khan.</p>
     <p class="mark">My name is khan.</p>
    <p>Khan is my title but i am maithil brahmin</p>
</body>
</html> 

==========================================================================================================================================



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Select Element by Name</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    // Highlight paragraph elements
    $("p").css("background", "red");
});
</script>
</head>
<body>
    <h1>Govind Ballabh Khan.</h1>
    <p>My name is khan.</p>
    <p>Khan is my title but i am maithil brahmin</p>

</body>
</html>


===========================================================================================================================================

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Select Element by Attribute</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    // Highlight paragraph elements
    $('input[type="text"]').css("background", "yellow");
    $('input[type="password"]').css("background", "blue");
});
</script>
</head>
<body>
    <form>
        <label>Name: <input type="text"></label>
        <label>Password: <input type="password"></label>
        <input type="submit" value="Sign In">
    </form>
</body>
</html>


===========================================================================================================================================


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Select Element by Compound Selector</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

    // Highlight li elements inside the ul elements
    $("ul li").css("background", "yellow");
 
    // Highlight li elements only inside the ul element with id mark
    $("ul#mark li").css("background", "red");
 
    // Highlight li elements inside all the ul element with class mark
    $("ul.mark li").css("background", "green");
 
   
});
</script>
</head>
<body>
    <p>This is a paragraph.</p>
    <p>This is another paragraph.</p>
    <p>This is one more paragraph.</p>
    <ul>
        <li>mango</li>
        <li>mango</li>
        <li>mango</li>
    </ul>
    <ul id="mark">
        <li>apple</li>
        <li>apple</li>
        <li>apple</li>
    </ul>
    <ul class="mark">
        <li>orange</li>
        <li>orange</li>
        <li>orange</li>
    </ul>
   
</body>
</html>                           



==========================================================================================================================================

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Custom Selector</title>
<style type="text/css">
    /* Some custom style */
    *{
        padding: 5px;
    }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    // Highlight table rows appearing at odd places
    $("tr:odd").css("background", "yellow");
 
    // Highlight table rows appearing at even places
    $("tr:even").css("background", "orange");
 
    // Highlight first paragraph element
    $("p:first").css("background", "red");
 
    // Highlight last paragraph element
    $("p:last").css("background", "green");
 
    // Highlight all input elements with type text inside a form
    $("form :text").css("background", "purple");
 
    // Highlight all input elements with type password inside a form
    $("form :password").css("background", "blue");
 
    // Highlight all input elements with type submit inside a form
    $("form :submit").css("background", "violet");
});
</script>
</head>
<body>
    <table border="1">
        <thead>
            <tr>
                <th>No.</th>
                <th>Name</th>
                <th>Email</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>1</td>
                <td>Govind Ballabh Khan</td>
                <td>govindkhan@mail.com</td>
            </tr>
            <tr>
                <td>2</td>
                <td>sanjay</td>
                <td>sanjay@mail.com</td>
            </tr>
            <tr>
                <td>3</td>
                <td>Dinesh</td>
                <td>dinesdh@gmail.com</td>
            </tr>
        </tbody>
    </table>
    <p>Govind Ballabh Khan.</p>
    <p>My Name is khan</p>
    <p>I am not muslim i am maithil brahmin</p>
    <form>
        <label>Name: <input type="text"></label>
        <label>Password: <input type="password"></label>
        <input type="submit" value="Sign In">
    </form>
</body>
</html>                           


=========================================================================================================================================

Tuesday, 24 July 2018

Summary table of Java Modifiers and Access Specifiers.
  • The only applicable modifier for the local variable is final.
  • The only applicable modifiers for constructor are public, private, default, protected.
  • The modifiers which are applicable only to the method is native.
  • The modifiers which are applicable only for variables volatile and transient.
  • The modifiers which are applicable for classes but not for an interface is final.
  • The modifier which is applicable for classes but not for enum is final, abstract.


Tuesday, 10 July 2018

//Array of ArrayList Demonstration in java
import java.util.*;
public class ArrayOfArrayList
{
  public static void main(String args[])
  {
    ArrayList listArray[] = new ArrayList[2];
 
    ArrayList firstList = new ArrayList();
    firstList.add("Java");   
    firstList.add("Technology");
 
    ArrayList secondList = new ArrayList();
    secondList.add("Govind");   
    secondList.add("Ballabh");
    secondList.add("Khan");

    listArray[0] = firstList;
    listArray[1] = secondList;
 
    System.out.println(listArray[0]);
    System.out.println(listArray[1]);
  }
}





                                 // Java program to illustrate creating an array of objects

class Student
{
    public int roll_no;
    public String name;
    Student(int roll_no, String name)
    {
        this.roll_no = roll_no;
        this.name = name;
    }
}

// Elements of array are objects of a class Student.
public class StudentDemo
{
    public static void main (String[] args)
    {
        // declares an Array of Student Object.
        Student[] arr;

        // allocating memory for 5 objects of type Student.
        arr = new Student[5];

        // initialize the first elements of the array
        arr[0] = new Student(1,"govind");

        // initialize the second elements of the array
        arr[1] = new Student(2,"ajit");

        // so on...
        arr[2] = new Student(3,"mani");
        arr[3] = new Student(4,"dinesh");
        arr[4] = new Student(5,"sanjay");

        // accessing the elements of the specified array
        for (int i = 0; i < arr.length; i++)
            System.out.println("Element at " + i + " : " +
                        arr[i].roll_no +" "+ arr[i].name);
    }
}






                                                     One Dimensional Array in java

public class OneDimensionalArray
{
  public static void main(String args[])
  {
    int marks[] = new int[5];

  System.out.println("Elements are " + marks.length);           

 // Now assign values
   
    marks[0] = 68;
    marks[1] = 70;
    marks[2] = 76;
    marks[3] = 85;
    marks[4] = 94;

  System.out.println("Value of 1st element: " + marks[0]);
  System.out.println("Value of 2nd element: " + marks[1]);
  System.out.println("Value of 3rd element: " + marks[2]);
  System.out.println("Value of 4th element: " + marks[3]);
  System.out.println("Value of 5th element: " + marks[4]);           

    System.out.println("Printing through  for  loop ");
    for(int i = 0; i < marks.length; i++)
    {
       System.out.println(marks[i] ); 
    }

    System.out.println("Printing through for each loop");
    for(int k : marks)
    {
        System.out.println(k);
    }   
  }
}





Monday, 9 July 2018

                                                                 //String array in java
public class Demo
{
public static void main(String args[ ])
{
String fname = "Govind";
String mname = "Ballabh";
String lname = "Khan";

System.out.println("========================Names===============================");
String names[] = {fname, mname, lname};
for(int i = 0; i < names.length; i++)
{
System.out.println(names[i]);
}
System.out.println("========================Cities===============================");
// we can create like this also
String cities[ ] = {"patna", "Bhopal", "Delhi"};
for(int i = 0; i < cities.length; i++)
{
System.out.println(cities[i]);
}
System.out.println("========================Language===============================");
// we can do like this also
String languages[ ] = new String[6];
languages[0] = "C";
languages[1] = "C++";
languages[2] = "Java";
languages[4] = ".Net";
languages[5] = ".Php";
for(int i = 0; i <languages.length; i++)
{
System.out.println(languages[i]);
}
}
}