:last Selector – Meaning and Usage :last selector fetches the last element from the collection of elements matched using a selector. Example, $(“span”) will select all span elements on the page. Adding the :last selector to the $(“span”) will return the last span out of those. If :last selector is used with another selector then, first the elements matching that selector are retrieved and then out of selected elements, those elements which are last in this list is returned. Example, $(“span.source:last”) will first retrieve those span elements which have the class source and then out of this collection, the last span is returned. :last-child selectorRead More →

Overview Determining the type of a value stored inside a variable is very important in any programming language but in javascript, it is extremely important. This is because a javascript variable can hold values of many types and just by looking at the variable definition, you cannot tell the value which it shall hold. Without knowing the type of value, operations performed on them can lead undesired result. Example, a variable can be written as : var x = 25; var x = “codippa”; Suppose you are adding 5 to the value of v, then it does not make any sense to perform add operationRead More →

Scenario A java.util.Map is returned from a Spring controller as a response to an ajax request from the server. This map, for example, contains names of students as values and their roll numbers as value. This is a sample data and it can be anything that has a key-value pair format. It can be names of Employees and their employee ids, it can be names of company offices and their countries, can be names of exams and their codes etc. This map needs to be attached as a source on a text box which should have autocomplete feature such that when someone starts typing, itRead More →

Overview A web element may have an attribute class with some value. An example is <input type = “text” class = “myClass”/>. The value of class name may represent a CSS(Cascading Style Sheet) styling rule which will be applied on elements having this class such as .myClass{ background-color : blue} or it may be used to distinguish it from other elements which do not have this class.Read More →

Scenario It might happen that on a certain event you want to reload or refresh a page. The events over which you may want to trigger page reload are click of a button, click of a link, selection of a checkbox. To reload or refresh a page, reload() function of javascript location object is used. Syntax is : location.reload() Usage Suppose there is a button on whose click the page needs to be refreshed. Basically, you need to call the above line of code on click of a button. This can be done in two ways : Using onclick attribute of button. This method isRead More →

Scenario There is an HTML table on a web page which shows a details of students in a class. In order to add a new student record to this table, there should be a button. When this button is clicked, a new row should be inserted at the end of the table. This can be done using jQuery. Below content shows how !!! There are two approaches to do this:Read More →