Saturday, July 22, 2017

HOW TO CREATE ACCORDION BY JQUERY

<!doctype html> <head> <link rel="stylesheet" href="jquery-ui.css"> <link rel="stylesheet" href="style.css"> <script src="jquery-1.12.4.js"></script> <script src="jquery-ui.js"></script> <script> $( function() { $( "#accordion" ).accordion(); } ); </script> </head> <body> <div id="accordion"> <h3>Section </h3> <div> <p> It is a long established fact that a reader will be distracted by the readable content
of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less
normal distribution of letters, </p> </div> <h3>Section 2</h3> <div> <p> There are many variations of passages of Lorem Ipsum available, but the majority have suffered
alteration in some form, by injected humour </p> </div> <h3>Section 3</h3> <div> <p> It is a long established fact that a reader will be distracted by the readable content of a
page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less
normal distribution of letters, </p> </div> </div> </body> </html>

HOW TO DISABLE RIGHT CLICK AND CUT,COPY,PASTE



<body> <h1 class="disable" >hey Myself Niraj Kumar </h1> </body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script> $('body').bind("cut copy paste", function(e) { alert('Cut Copy Paste is disabled..'); e.preventDefault(); }); </script> <script> $('.disable').bind("cut copy paste", function(e) { alert('Cut Copy Paste is disabled..'); e.preventDefault(); }); </script>

HOW TO SEE PREVIEW OF IMAGES BEFORE UPLOAD

<form id="form"> <input type='file' id="file" /> <br/> <span style="color:red"> Note: Please select only image file (eg: .png, .jpeg, .jpg, .gif etc)</span><br/> <img id="img" src="http://placehold.it/200x200" alt="No image uploaded" /> </form> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script> $(function() { $("#file").change(function () { readImgPath(this); }); // read image path function readImgPath(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $('#img').attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } }) </script>

HOW TO EXPORT TABLE TO EXCEL FORMATE BY JQUERY

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <script src="jquery.table2excel.js"></script> <script> $(function() { $(".download").click(function() { $(".tb2excel").table2excel({ exclude: ".noExl", name: "Excel Document Name", filename: "file_name", fileext: ".xls", exclude_img: true, exclude_links: true, exclude_inputs: true }); }); }); </script> <table class="tb2excel" border=1> <tr><th>S.No.</th><th> Name</th><th> Email</th><th> Phone</th><tr> <tr><td>1</td><td> Niraj Singh</td><td> nirajsgh15@gmail.com</td><td> 1000000000</td><tr> <tr><td>3</td><td> Astha Kumari</td><td> ma@abc.in</td><td> 1000000001</td><tr> <tr><td>3</td><td> Sagar Kumar</td><td> abc@gmail.com</td><td> 1000000011</td><tr> <tr class="noExl"><td>..</td><td> ..</td><td> ..</td><td> ..</td><tr> </table> <h3><a href="#" class="download">Export Excel</a></h3>