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