Posts

Showing posts with the label JAVA SCRIPT

Java Script Arrays -POP Method

To Remove the Last element of An Array this pop Method is used . <!DOCTYPE html> <html> <body> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo").innerHTML = fruits; function myFunction() { fruits.pop(); document.getElementById("demo").innerHTML = fruits; } </script> </body> </html> Example Explained : When user clicks on the button the myFunction is called . inside the myFunction() pop() method will be executed which will remove the last element of the Array.  After removing it will access the div with id of demo and insert the array elements

How To Remove Elements In Array

With Slice method we can remove the Elements in Array . The following code snippet is an Example of the Same. <!DOCTYPE html> <html> <body> <p>Click the button to extract the second and the third elements from the array.</p>   By Clicking the following button we are calling the myFunction ()  Function . <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { now we have a variable "fruits " which contains the following Data .     var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"]; With the slice method we can remove element in side an Array . In the following example we want to remove one elements which is in the 1st and 3rd index position of the Array . It will slice that particular elements in and returns the balance elements  which will be stored in "citrus ". ...

How to delete the selected Div

here is simple image gallery Program . When we Click that particular div will be deleted  . it will delete all the div until the last Element. Here is the Code <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <title></title>     <style>         #box1, #box2, #box3, #box4, #box5 {             width:150px;             height:150px;             border:1px solid red;             display:block;                   }         li {     display: inline; } #box1{     background-color:red; ...

How to hide and show a element with if else condition .

How to hide and show a element with if else condition . in this program , when we click the button it will check the 'myDiv' is hidden or not . If it is hidden it will change the css property so that the element will show . other wise it will be hide . <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>     <title></title>     <style>     #myDiv{         width:300px;         height:200px;         background:Red;            }         </style> </head> <body>     <div id="myDiv">     </div>     <button onclick="myFunction()">Click</button><!-- When user clicks on the this Button it will call myFunctio...

How to Loop through the Java Script Arrays

Image
How to iterate the data in an Array or the j son ? Fist Let us have one simple Array with few objects inside Example: var states=[{"name":"Andhra Pradesh"}, {"name":"Karnataka"}, {"name":"Telangana"}, {"name":"Kerala"}, {"name":"Tamil Nadu"} ] To display the Data we have to loop the Array . So let us use for loop for the same ; for (var i =0;i<states.length;i++){  document.write (states[i].name) } If you have multiple data values in the objects inside the array , you have to use the property of that object next to the array . For example let us add one more value to the existing Array . var states=[{"name":"Andhra Pradesh","capital":"Amaravathi"}, {"name":"Karnataka","capital":"Bangalore"}, {"name":"Telangana","capital":"Hyderabad"}, {...

Java Script arrays

Image
Java Script arrays are used to store multiple values  in a single variables . It may single value or collection of objects . Arrays are very important in Java Script. Let us look how can we create arrays in Java Script. we can create Java script arrays as follows . var subjects=["Telugu","Tamil","Hindi","English "] ; we can also create Java script arrays  as follows var subjects=[]; this indicates an empty array with the name of subjects; let us add some values for the arrays . Arrays value positions are started from 0 . It means in the above example the index (position )  of the Telugu is "0", and Tamil is "1", so we can add the values for the array in as follows. subjects[0]="Telugu"; subjects[1]="Tamil"; How can we retrieve or Iterate the Data from an array ? we can do it in two different methods .  The first way of doing this is by using the for loop . First wee need to find out th...

javascript objects tutorial

In JavaScript Every thing is considered as an Object except Boolean Values . Creating and Objects and accessing its properties are very important tasks in Java script. Let us discuss about an object with an Examples . Let us create an object of a "Person" <script> var person={}; This Indicates an empty object with a name of person. person.firstName="Murali"; This indicates Object having a property of First Name and its value is Murali. person.lastName="Krishna"; This indicates Object having a property of First Name and its value is Krishna. person.company="HP";This indicates Object having a property of Company  and its value is HP. </script> Now Let us look how can we access the object Properties . To access the Property of an object we have to access the object. Console.log(person.firstName); it will give the value of the person Fist name . In same way we can access all the properties.

How To Create A multiplication Table

Hi Friends i Have create a simple program to Display the Multiplication Table . In This I have used two For loops . Step 1: We will get the user input and we are storing that value in to " table " variable as follows. var table = prompt("How Many Tables you Want"); Step 2 : We are starting our table from to and we will with the User data "table " with the following  for Loop  for (var i = 2; i <=table ; i++); Then we are creating the div dynamically and inserting the Generated As Follows.. <!DOCTYPE html> <head>     <title></title>     <style>        div {         float: left;     margin: 10px;     font-size:large;     width: 130px; }     </style> </head> <body>     <script>         (function () {   ...

HTML Tutorials In Telugu

Image
Hi Friends , I Have started a HTML Tutorial Channel in Telugu . I thing this may be helpful for the people who wants to start their career as HTML Developer or web developer. I request you people to share it for the other people .

Importance of Javascript In UI Developer Career .

In initial days we wont have the clear picture about the role of JavaScript In UI developer Career.   Once you get in to the JOB we will come to know the real picture of the JavaScript . But it is beyond our imagination . If you are serious about building a career in UI Development i personally recommend you to concentrate more on the JavaScript  . I have attended so many interviews recently and faced  so many questions . In that the major questions i have faced about JavaScript only . HTML & CSS Questions are very less , So try to concentrate more on JavaScript More.. And we should have an idea about the Java script Frame works like J Query , AngularJs . So start practicing the JavaScript and  Jquery .  Once we start to study about the JavaScript we will to know where and how it is being used . There is so much information is available on net . So Just search about some basics and study . Some of the important Topic we must Concentrate on JavaScri...