How to use Chrome browser as a Notebook device browser

How to use Chrome browser as a Samsung mobile device browser


How to use Google Chrome browser as a Apple IPhone mobile Browser

How to use Chrome browser as a Sony mobile device browser


How to use Google Chrome browser as a Google Nexus mobile browser


How to use Google Chrome browser as a LG Optimus mobile browser


How to Debug JQuery Code in Internet Explorer must watch


How to debug JQuery Code in the Mozilla Firefox Browser with out firebug


How to install Firebug add on in the mozilla browser

How to install Firebug add on in the mozilla browser

How to debug JQuery Code using Chrome Browser

How to use Chrome browser as a HTC mobile device browser

How to use Chrome browser as a Motorola mobile device browser

How to use Chrome browser as a Nokia mobile device browser

How to do Check box check event dynamically?


Some times we may have some values are attaching to the checkbox ids, like example below. Using $("[Id*='isAccommadation']") code we can get selected checkbox value and we can do the event operations.

This is not limited to check box. This will applicable for all HTML elements.


<!DOCTYPE html>

<html>

<head>

    <title></title>

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

    <script language="javascript">

        $(document).ready(function() {



            $("[Id*='isAccommadation']").bind("click", function () {

                alert(this.value);

            });



        });

    </script>

</head>

    <body>

        <div id="hai">



        <input type='checkbox' name="1" id='isAccommadation_1' value="JQuery" />JQuery<br/>

        <input type='checkbox' name="2" id='isAccommadation_2' value="Example" />Example<br/>

        <input  type='checkbox' name="3" id='isAccommadation_3' value="Code" />Code<br/>

            </div>

    </body>

</html>


How to remove tag using JQuery but without tag inner content?

Remove tag using JQuery


We can remove HTML tag using jquery by different scenarios.

1. $('a').contents().unwrap();

This will remove the anchor tag but keep the anchor inner HTML.

2. Come to performance view below code is useful.

var b = document.getElementsByTagName('a');
while(b.length) {
    var parent = b[ 0 ].parentNode;
    while( b[ 0 ].firstChild ) {
        parent.insertBefore(  b[ 0 ].firstChild, b[ 0 ] );
    }
     parent.removeChild( b[ 0 ] );
}


3. We can also use replaceWith JQuery function. Please check below example.

$("a").replaceWith(function() { return $(this).contents(); });

If any other ways, please share in the comments section.

Is DOM element has been hidden or shown using jQuery?

Below JQuery samples will show you, how to find out hidden DOM element.


// Checks for display:[none|block], ignores visible:[true|false]
$(DOMElement).is(":visible")

//some more complete information
$(".item").each(function() {
if ($(this).css("visibility") == "hidden") {
// handle non visible state
} else {
// handle visible state
}
});
var isHidden = $('DOMElement').is(':hidden');

// Matches all elements that are hidden
$('DOMElement:hidden')

// Matches all elements that are visible.
$('DOMElement:visible')

//Functions don't work with the visibility attribute.
$(DOMElement).css('display') == 'none'

 

Redirect one webpage to other using Javascript/JQuery

There are so many ways to redirect one javascript file to other. As per my knowledge i am showing below ways, If any one knows any other way they can tell in the comments section.



// it won't store information about previous page.
window.location.replace("http://aspnettutorialonline.blogspot.com/");

// best way to use
window.location.href = "http://aspnettutorialonline.blogspot.com/";

//using javascript only.
window.location = "http://aspnettutorialonline.blogspot.com/";


//Using JQuery way - 1
var url = "http://aspnettutorialonline.blogspot.com/";   
$(location).attr('href',url);


//Using JQuery way  - 2.
$jq(window).attr("location","http://aspnettutorialonline.blogspot.com/");

//redirecting to the home page.
window.location = window.location.host

How to implement validations on form controls using javascript before a postback occurs.


If we are using submit button in the form, we have to validation data before sending to the server. For this on submit we will call the javascript method. from the method we will return true or false based on the validation result.


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
        function Validate() {
            //Need to do validations here. 
            //If any thing fails we have to return false other wise request go to server
        }
    </script>
</head>
<body>
    <form onsubmit="return Validate()">
        ... all controls will go here with submit button...
    </form>
</body>
</html>


If you have any queries or suggestions, please feel free to ask in comments section.