Thursday, August 28, 2014

Disable Cut,Copy and Paste using jquery

In this article am going to show how to Disable Cut,Copy and Paste using jquery.


Jquery Function

<script>

            $(document).ready(function() {
                $('#input').bind("cut copy paste", function(e) {
                            alert('cut,copy & paste options are disabled');
                            e.preventDefault();
                        });

</script>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Wednesday, August 27, 2014

Remove Same Strings Using JQuery

This script is used to remove duplicates entry for string.remove() method is used to remove the strings.




Live DemoDownload Script


Need library file to perform this action.Please copy and Paste below library file.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js"></script>

Jquery Function

<script type='text/javascript'>
        $(window).load(function(){
        var txtString = {};
        $('p').each(function() { //Get all strings using p tag
            var txt = $(this).text();
            if (txtString[txt]){
                $(this).remove(); //remove same string
            }else{
                txtString[txt] = true;
                }
        });
        });

    </script>

HTML Code

<p>Java</p>
  <p>Joomla</p>
  <p>PHP</p>
  <p>CSS</p>
  <p>PHP</p>
  <p>Joomla</p>
  <p>Java</p>


Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Friday, August 22, 2014

Get Browser details using jQuery

Get Browser details using jQuery


Live DemoDownload Script

Need library file to perform this action.Please copy and Paste below library file.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>

Jquery Function For IE Browser

 <script type="text/javascript">
        $(document).ready(function () {
            $("#browserdetails").click(function () {
                if ($.browser.msie) {
                    var browsername = "Microsoft Internet Explorer";
                }
                var bversion = $.browser.version;
                alert("Browser: " + browsername + "  Version: " + bversion);
                return false;
            });
        });
    </script>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

jQuery plugin for Uppercase, Lowercase and titlecase

jQuery plugin for UpperCase, LowerCase and TitleCase


Blink Effect with random colors using Javascript

Blink Effect with random colors using Javascript





Jquery Function For IE Browser

<script type="text/javascript">
        setInterval(colors, 1000); //Set Interval time
        function colors() {
            var color = "rgb("
            + Math.floor(Math.random() * 255) + ","
            + Math.floor(Math.random() * 255) + ","
            + Math.floor(Math.random() * 255) + ")";
            document.getElementById("txtName").style.color = color; //Get Element value and apply style for that element
        }
        </script>

HTML Code

<div id="txtName">CodeInnovators is a programming blog maintained by Vinothkumar S. Tutorials focused on Jquery,Ajax,PHP,HTML5,CSS3,Wordpress,Joomla,Drupal and MYSQL</div>

Thursday, August 21, 2014

How to add SEO title for Categories in Wordpress

How to add SEO title for Categories in Wordpress

Open your functions.php file.Add the following lines.

File path: wp-content/themes/your-theme/functions.php

Store SEO titles in array with Category ID.

Function

$pagetitels = array(
            13 => 'Your Category Custom title', //Category ID and custom title
            18 => 'Your Category Custom title',
            17=> 'Your Category Custom title'
        );

Create function to overwrite default titles.

Function

function change_cptitle() {
    global $pagetitels;
    $catid = get_query_var('cat'); //Get Category ID
    if (array_key_exists($catid, $pagetitels)) {
        $title = $pagetitels[$catid]; // use a custom title
    } else {
        $title = get_the_category_by_ID($catid); // use the category name as title
    }
    return $title;
    }

Full Code

$pagetitels = array(
            13 => 'Chennai Real Estate Guide 2014| Chennai Property magazine ',
            18 => 'Luxury Living | Luxury Real Estate Magazine',
            17=> 'Architectural magazine | Architecture design ideas '
        );
        function change_cptitle() {
    global $pagetitels;
    $catid = get_query_var('cat'); //Get Category ID
    if (array_key_exists($catid, $pagetitels)) {
        $title = $pagetitels[$catid]; // use a custom title
    } else {
        $title = get_the_category_by_ID($catid); // use the category name as title
    }
    return $title;
    }
add_filter("single_cat_title", "change_cptitle");

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Wednesday, August 20, 2014

Merge Multiple Tables into single table using jQuery

This is very simple script used to merge tables.
append() method insert elements at the end of the selected content.
prepend() method insert elements starting of the selected content.

In this example i have used both append() and prepand() methods.




Add tables at Last:
Add tables at First:
Need library file to perform this action.Please copy and Paste below library file.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>


Add tables at Last:

Jquery Function

<script type="text/javascript">
        $(function() {
            $('#Merge').click(function() {
                $('#tbl1 > tbody:last').append($('#tbl2 > tbody').html());
                $('#tbl1 > tbody:last').append($('#tbl2 > tbody').html());
                $('#tbl2').remove();
                $('#tbl3').remove();
            });
        });
    </script>

remove() method removes data for selected elements.

Add tables at First:

Jquery Function

<script type="text/javascript">
    $(function() {
        $('#Merge').click(function() {
            $('#tbl1 > tbody:first').prepend($('#tbl2 > tbody').html());
            $('#tbl1 > tbody:first').prepend($('#tbl3 > tbody').html());
            $('#tbl2').remove();
            $('#tbl3').remove();
        });
    });
</script>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.