Posts

Showing posts from February, 2013

Featured Post

Jquery,hasClass

Returns: Boolean .hasClass(className) className The class name to search for. Determine whether any of the matched elements are assigned the given class. Elements may have more than one class assigned to them. In HTML, this is represented by separating the class names with a space: The .hasClass() method will return true if the class is assigned to an element, even if other classes also are. For example, given the HTML above, the following will return true: $('#mydiv').hasClass('foo') As would: $('#mydiv').hasClass('bar') While this would return false: $('#mydiv').hasClass('quux') Example Demo Looks for the paragraph that contains 'selected' as a class. This paragraph is black and is the first paragraph. This paragraph is red and is the second paragraph. First paragraph has selected class: Second paragraph has selected class: At least one paragraph has selected class:

Jquery attr()

.attr() .attr(attributeName) Get the value of an attribute for the first element in the set of matched elements. .attr(attributeName, value) Set one or more attributes for the set of matched elements. Returns: String .attr(attributeName) attributeName The name of the attribute to get. Get the value of an attribute for the first element in the set of matched elements. The .attr() method gets the attribute value for only the first element in the matched set. To get the value for each element individually, use a looping construct such as jQuery's .each() or .map() method. As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. In addition, .attr() should not be used on plain objects, arrays, the window, or the document. To retrieve and change DOM properties, use the .prop() method. Using jQuery's .attr() method to get the value of an element's attribute has two main benefits: Convenience: It can be called directly on a jQu...

Jquery .addClass

.addClass() Returns: jQuery .addClass(className) className One or more class names to be added to the class attribute of each matched element. .addClass(function(index, currentClass)) function(index, currentClass) A function returning one or more space-separated class names to be added. Receives the index position of the element in the set and the old class value as arguments. Adds the specified class(es) to each of the set of matched elements. It's important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements. More than one class may be added at a time, separated by a space, to the set of matched elements, like so: $("p").addClass("myClass yourClass"); This method is often used with .removeClass() to switch elements' classes from one to another, like so: $("p").removeClass("myClass noClass").addClass("yourClass"); Here, the...

Jquery addClass

.addClass() Returns: jQuery .addClass(className) className One or more class names to be added to the class attribute of each matched element. .addClass(function(index, currentClass)) function(index, currentClass) A function returning one or more space-separated class names to be added. Receives the index position of the element in the set and the old class value as arguments. Adds the specified class(es) to each of the set of matched elements. It's important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements. More than one class may be added at a time, separated by a space, to the set of matched elements, like so: $("p").addClass("myClass yourClass"); This method is often used with .removeClass() to switch elements' classes from one to another, like so: $("p").removeClass("myClass noClass").addClass("yourClass"); Here, the...

Jquery. Val()

.val() .val() Get the current value of the first element in the set of matched elements. .val(value) Set the value of each element in the set of matched elements. Returns: String, Number, Array .val() Get the current value of the first element in the set of matched elements. The .val() method is primarily used to get the values of form elements. In the case of elements, the .val() method returns an array containing each selected option. For selects and checkboxes, you can also use the :selected and :checked selectors to get at values, for example: $('select.foo option:selected').val(); // get the value from a dropdown select $('select.foo').val(); // get the value from a dropdown select even easier $('input:checkbox:checked').val(); // get the value from a checked checkbox $('input:radio[name=bar]:checked').val(); // get the value from a set of radio buttons Example Demo Get the single value from a sin...

Toggle class

.toggleClass() Returns: jQuery .toggleClass(className) className One or more class names (separated by spaces) to be toggled for each element in the matched set. .toggleClass(className, switch) className One or more class names (separated by spaces) to be toggled for each element in the matched set. switch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. .toggleClass(function(index, class), [switch]) function(index, class) A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set and the old class value as arguments. switch A boolean value to determine whether the class should be added or removed. Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. This method takes one or more class names as its parameter. In ...

Jquery removeProp

.removeProp() Returns: jQuery .removeProp(propertyName) propertyName The name of the property to set. Remove a property for the set of matched elements. The .removeProp() method removes properties set by the .prop() method. With some built-in properties of a DOM element or window object, browsers may generate an error if an attempt is made to remove the property. jQuery first assigns the value undefined to the property and ignores any error the browser generates. In general, it is only necessary to remove custom properties that have been set on an object, and not built-in (native) properties. Note: Do not use this method to remove native properties such as checked, disabled, or selected. This will remove the property completely and, once removed, cannot be added again to element. Use .prop() to set these properties to false instead. Example Demo Set a numeric property on a paragraph and then remove it.

Jquery removeClass

.removeClass() Returns: jQuery .removeClass([className]) className One or more space-separated classes to be removed from the class attribute of each matched element. .removeClass(function(index, class)) function(index, class) A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. Remove a single class, multiple classes, or all classes from each element in the set of matched elements. If a class name is included as a parameter, then only that class will be removed from the set of matched elements. If no class names are specified in the parameter, all classes will be removed. More than one class may be removed at a time, separated by a space, from the set of matched elements, like so: $('p').removeClass('myClass yourClass') This method is often used with .addClass() to switch elements' classes from one to another, like so: $('p').remo...

Remove attr,removeAttr in jquery

.removeAttr() Returns: jQuery .removeAttr(attributeName) attributeName An attribute to remove. Remove an attribute from each element in the set of matched elements. The .removeAttr() method uses the JavaScript removeAttribute() function, but it has the advantage of being able to be called directly on a jQuery object and it accounts for different attribute naming across browsers. Note:If attempting to remove an inline 'onclick' event handler using .removeAttr(), one may find that this doesn't achieve the desired effect in Internet Explorer 6,7 or 8. Instead it is recommended to opt for using .prop() to achieve this as follows: $element.prop("onclick", null); console.log("onclick property: ", $element[0].onclick); We may update the behavior of .removeAttr() at some point in the future to better handle this, however for the time being, the above should be considered the standard cross-browser approach to this problem. Example Demo Clicking the...

Jquery.prop()

.prop() .prop(propertyName) Get the value of a property for the first element in the set of matched elements. .prop(propertyName, value) Set one or more properties for the set of matched elements. Returns: String .prop(propertyName) propertyName The name of the property to get. Get the value of a property for the first element in the set of matched elements. The .prop() method gets the property value for only the first element in the matched set. It returns undefined for the value of a property that has not been set, or if the matched set has no elements. To get the value for each element individually, use a looping construct such as jQuery's .each() or .map() method. The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop() method provides a way to expli...

Jquery .html()

.html() .html() Get the HTML contents of the first element in the set of matched elements. .html(htmlString) Set the HTML contents of each element in the set of matched elements. Returns: String .html() Get the HTML contents of the first element in the set of matched elements. This method is not available on XML documents. In an HTML document, .html() can be used to get the contents of any element. If the selector expression matches more than one element, only the first match will have its HTML content returned. Consider this code: $('div.demo-container').html(); In order for the following 's content to be retrieved, it would have to be the first one with class="demo-container" in the document: Demonstration Box The result would look like this: Demonstration Box This method uses the browser's innerHTML property. Some browsers may not return HTML that exactly replicates the HTML source in an original document. For example, Internet Expl...

Jquery hasClass()

.hasClass() Returns: Boolean .hasClass(className) className The class name to search for. Determine whether any of the matched elements are assigned the given class. Elements may have more than one class assigned to them. In HTML, this is represented by separating the class names with a space: The .hasClass() method will return true if the class is assigned to an element, even if other classes also are. For example, given the HTML above, the following will return true: $('#mydiv').hasClass('foo') As would: $('#mydiv').hasClass('bar') While this would return false: $('#mydiv').hasClass('quux') Example Demo Looks for the paragraph that contains 'selected' as a class. This paragraph is black and is the first paragraph. This paragraph is red and is the second paragraph. First paragraph has selected class: Second paragraph has selected class: At least one paragraph has selected class:

Include directive vs include action

Image
Friends currently reading scwcd Came across interview question Difference between include directive and action Include directive @ translation time file content will be merged with main jsp But include action which executes for every request it hampers performance issue but include directive will not Please find attached image for more differences

Hibernate in action

Image
This book I am currently reading to understand better on orm framework Thanks

Jquery .attr()

.attr(attributeName) Get the value of an attribute for the first element in the set of matched elements. .attr(attributeName, value) Set one or more attributes for the set of matched elements. Returns: String .attr(attributeName) attributeName The name of the attribute to get. Get the value of an attribute for the first element in the set of matched elements. The .attr() method gets the attribute value for only the first element in the matched set. To get the value for each element individually, use a looping construct such as jQuery's .each() or .map() method. As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. In addition, .attr() should not be used on plain objects, arrays, the window, or the document. To retrieve and change DOM properties, use the .prop() method. Using jQuery's .attr() method to get the value of an element's attribute has two main benefits: Convenience: It can be called directly on a jQuery objec...