Google+
Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Tuesday, June 11, 2013

Testing if something is hidden with jQuery

In jQuery, it is possible to toggle the visibility of an element. You can use the functions .hide(),.show() or .toggle().
How you would test if an element has been hidden or shown using jQuery?

As, the question refers to a single element, this code might be more suitable:
$(element).is(":visible") // Checks for display:[none|block], ignores visible:[true|false]

Note:-Please comment and reply me.

Saturday, July 30, 2011

Dynamically create a accordion by java script and jquery


Suppose , you have to dynamically get 10 accordion or any number of accordion , there are mainly two solution : whether you create a all accordion by manually or you create that accordion dynamically .



First all create a div with any id , i create a div with accordion id .


            <div id="accordion">
            </div>

   
 Second add script to generate dynamically accordion .


   <script type="text/javascript">

        $(document).ready(function () {     
            BindEnvironments();
        });


 function BindEnvironments() {

            var text = $("#accordion");
            for (var i = 0; i < 10; i++) {
                var content = '<h5><a href="#" id="hf' + i + '" >' + i + '</a></h5>';
                content += '<div id="dv' + i + '">AAA</div> ';
                $("#accordion").append(content);
            }
            $("#accordion").accordion({
                collapsible: false,
                autoHeight: false,
                active: -1
            });
        }

</script>



Note:-Please comment and reply me.

Saturday, May 28, 2011

Regular Expression For Mobile validation



         Hi , regular expression is a text matching mechanism . suppose you want to validate whether given input to textbox is mobile number or not? , then regular expression is good way.


         To validate mobile like(+9548508412 or 9548508412 or  95485084121 ) , means if you want that mobile number should be at least 10 digit long and  '+' is optional ,  you can use these regular expression :


\+?\d{10,}





Note:-Please comment and reply me.

Sunday, April 24, 2011

Jquery


What is jQuery?


  • A framework for Client Side JavaScript.
  • Frameworks provide useful alternatives for common programming tasks, creating functionality which may not be available or cumbersome to use within a language.
  • An open source project, maintained by a group of developers, with a very active support base and thorough, well written documentation.
  • jQuery is built on top of JavaScript, a rich and expressive language in its own right.


jQuery Syntax:-


$.func(…); 
or 
$(selector).func1(…).func2(…).funcN(…);



$             jQuery Object, can be used instead of  jQuery
selector   Selector syntax, many different selectors allowed
func        Chainable, most functions return a jQuery object
(…)        Function parameters



Note:-Please comment and reply me.