In this example i am going to explain about how to check a object is visible or not in the form.
Steps to follow:
1. :visible selector in jQuery Selects all elements that are visible. To get all visible divs inside a div with id "parentdiv" you can use below code.
$('#parentdiv').find('div:visible').each(function
() {
// your code....
});
2. To check whether div with id "parentdiv" is visible use the below code.
if ($('#parentdiv').is(':visible')) {
// your code....
}
3. To check whether div with id "parentdiv" is hidden use the below code.
if ($('#parentdiv').is(':hidden')) {
// your code....
}
Important Note:
To achieve the best performance when using :visible or :hidden to select elements, first select the elements using a pure CSS selector, then use .filter(":visible") / .filter(":hidden")
Example:
if ($('#parentdiv').is(':visible')) {
// your code....
}
Do you like this article? Help us to improve. Please post your comments below.
Other JQuery Articles you may like
- Check div/element/object is visible or hidden using Jquery - New !!
- Add remove select and set items in select drop down list
- Bind unbind event in jQuery
- Check uncheck all checkboxes in grid view using jquery
- Get current url using JavaScript jQuery
- How to get the keycode for different browser for keyboard characters
- Move items in drop down list from left to right using jQuery
Comments
Post a Comment