Wednesday, 6 September 2017

How to Select / Deselect All Checkboxes using jQuery

How to Select / Deselect All Checkboxes using jQuery
If you are developer and looking for a jQuery code-snippet that selects and de-selects multiple checkboxes by clicking “Select All” checkbox, like in Gmail.com, rediffmail.com and yahoo.com. Then you are at right place. 

This is very simple and most commonly used in web application and specially its used where there is multiple record listing. 

In Admin section,  this functionality is needed in every page, like User Listing, Product Listing, Album Listing  & images listing etc. 

When selected "Select All" checkbox, It will select all the checkbox under the main checkbox. 
If you de-select the "Select All", It will de-select all the checkbox under this main checkbox.



You can use below code and do the modification as per your requirement. This code is very useful not just in current web application but also for future.

select all checkbox jquery DEMO


 
Select All
Name2
Name3
Name4
Name5
Name6
Code Snippet
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script type="text/javascript"> 

jQuery(document).ready(function() {

    jQuery('#checkbox_all').click(function(){ 
        
        if($(this).is(":checked")){ 
            jQuery('input[type="checkbox"].chk').each(function(){ 

                jQuery(this).prop("checked",true);

            });         

        }else{ 

            jQuery('input[type="checkbox"].chk').each(function(){ 

                jQuery(this).prop("checked",false);

            });                 

        } 

     

    }); 

}); 

</script> 
<table border="1" rules="groups" style="width: 200pxpx;">
<tbody>
<tr> 

        <th><input id="checkbox_all" name="checkbox" type="checkbox" /></th> 

        <th>Select All</th> 

    </tr>
<tr> 

        <td><input class="chk" name="checkbox" type="checkbox" /></td> 

        <td>Name2</td> 

    </tr>
<tr> 

        <td><input class="chk" name="checkbox" type="checkbox" /></td> 

        <td>Name3</td> 

    </tr>
<tr> 

        <td><input class="chk" name="checkbox" type="checkbox" /></td> 

        <td>Name4</td> 

    </tr>
<tr> 

        <td><input class="chk" name="checkbox" type="checkbox" /></td> 

        <td>Name5</td> 

    </tr>
<tr> 

        <td><input class="chk" name="checkbox" type="checkbox" /></td> 

        <td>Name6</td> 

    </tr>
</tbody></table>





Tuesday, 5 September 2017

Microdata in HTML5

Microdata in HTML5

Question: What is Microdata in HTML5?
Microdata is a way to provide additional semantics in your web application.


Question: What is use of Microdata?
  1. Define your own customized elements.
  2. Define custom properties.
  3. We use itemscope and itemprop attribute



Question: Give sample URL of Microdata?
    
        <div itemscope="">
Web Site <span itemprop="name">Web technology experts</span>.</div>
<div itemscope="">
Domain URL is <span itemprop="name">http://web-technology-experts-notes.in</span>.</div>




Question: What are different attributes of Microdata?
Attribute Description
itemscope The itemscope attribute is a boolean attribute that tells there are Microdata on this page.
itemtype It is valid URL which defines the item.
itemid Global identifier for the item.
itemprop Property of the item.
itemref List of additional elements to crawl.



Question: What are the importance of microdata in SEO?
Schema is a specific vocabulary of tags (microdata) that you can add to your HTML to improve the way your page is represented in SERPs.


Question: What is full form of SERPs?
A search engine results page (SERP) is the page displayed by a search engine in response.


Question: What does schema org do?
Schema.org is a joint effort, in the spirit of sitemaps.org, to improve the web by creating a structured data markup schema supported by major search engines.


Question: What is Google schema?
Schema.org is the centralized home on the web for the Schema project, a collaboration between Google, Bing and Yahoo! to standardize structured markup.


Question: What is rich snippets in Google?
Rich Snippets is the term to describe structured data markup that site can add to their HTML, which in turn allow search engines to better understand.


Question: What are rich cards Google?
These "rich results" are facilitated by the addition of structured data markup to web pages, either in the form of content items ("such as articles, recipes, or movies") or lists.