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.

Tuesday, August 19, 2014

Different menu background color for each tab using CSS

Different menu background color for each tab using CSS


I have used ul,li for tabs and used div for content.Add id for body tag.

HTML

<body id="home">
    <ul id="menu">
        <li class="home"><a href="index.html">Home</a></li>
    </ul>
    </body>

Apply different background for particular tab.

CSS Code

body#home ul#menu {background:#B8860B}
        body#home .content {background:#BDB76B}

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

Monday, August 18, 2014

Get Current Page Url using jQuery

Get Current Page Url using jQuery


Live DemoDownload Script


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

jQuery Function

<script type="text/javascript">
            $(function () {
                var url = $(location).attr('href');
                var title= $(this).attr('title');
                    $('#title').html('<strong>' + title + '</strong>');
                    $('#url').html('<strong>' + url + '</strong>');
                });
            </script>

HTML

<p>Current page URL: <span id="url"></span></p>
        <p>Current page title: <span id="title"></span></p>

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

Allow only alphabets in textbox using jquery

Allow only alphabets in textbox using jquery



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>


jQuery Function

<script type="text/javascript">
        $(function () {
            $('#txtvalue').keydown(function (e) {
                        if (e.shiftKey || e.ctrlKey || e.altKey) {
                        e.preventDefault();
                    } else {
                        var key = e.keyCode;
                        if (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) {
                        e.preventDefault();
                    }
                }
            });
        });
        </script>

HTML

Enter Your Text:<input type="text" id="txtvalue" />

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

Thursday, August 14, 2014

Check if string contains special characters or not using jQuery

This is very simple javascript code.it is used to check if string contains special characters or not.

Step 1: Need library file to perform empty action.Please copy and Paste below library file.

jQuery Function

<script type="text/javascript">
        $(function () {
            $('#btncheck').click(function () {
                var txt = $('#txtValue').val(); //Entered Value
                if (/^[a-zA-Z0-9- ]*$/.test(txt) == false) {
                    alert('Your String Contains illegal Characters');
                }
                else
                {
                    alert('Your String Not Contains illegal Characters');
                }
            })
        })
    </script>

HTML

Enter Your Text:
    <input type="text" id="txtValue" />
    <input type="button" id="btncheck" value="Check" />

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

Wednesday, August 6, 2014

jQuery disable right click on webpage

jQuery disable right click on webpage


Live DemoDownload Script

Step 1:
Need library file to perform empty action.
Please copy and Paste below library file.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

jQuery disable right click

<script type="text/javascript">
        $(function() {
            $(this).bind("contextmenu", function(e) {
                e.preventDefault();
                alert("Right Click is not allowed");
            });
        });
    </script>

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