Showing posts with label Jquery. Show all posts
Showing posts with label Jquery. Show all posts

Tuesday, 5 August 2014

Features of Jquery

Features of Jquery 
1. One can easily provide effects and can do animations. 
2. Applying / Changing CSS. 
3. Cool plugins. 
4. Ajax support 
5. DOM selection events 
6. Event Handling 


and many more other feature provide by jquery.

difference between e.preventDefault(); and return false

The difference is that preventDefault will only prevent the default event action to occur, i.e. a page redirect on a link click, a form submission, etc. and return false will also stop the event flow.

Tuesday, 1 July 2014

Attach data of any type to DOM elements in Jquery.

The .data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks.


$( "div" ).data( "foo", 52 );
$( "div" ).data( "bar", { myType: "test", count: 40 } );
$( "div" ).data( { baz: [ 1, 2, 3 ] } );
$( "div" ).data( "foo" ); // 52
$( "div" ).data(); // { foo: 52,  // bar:{ myType: "test", count: 40 }, // baz: [ 1, 2, 3 ] } Example:
<body>
<div>
The values stored were
<span></span>
and
<span></span>
</div>
<script>
$( "div" ).data( "test", { first: 16, last: "pizza!" } );
$( "span:first" ).text( $( "div" ).data( "test" ).first );
$( "span:last" ).text( $( "div" ).data( "test" ).last );
</script>
</body>
Output:The values stored were 16 and pizza!

Thursday, 26 June 2014

How to create Widget in JQUERY..

(function ($) {

    $.widget('AZ.azAddNewDiscussion', $.AZ.Node, {
        options: {
          data: null      
        },
        widgetEventPrefix: $.AZ.Node.prototype.widgetEventPrefix,

        _create: function () {               // create event
            this._addNewDiscussion();

            this._on(this.element, {
                'click': function (event) {              
                },
                'click #newDiscussionNode': function (event) {
                    alert('button click');
                }

            });
        },
        _addNewDiscussion: function () {
     
          var buttonElemet = $("<h6 id='newDiscussionNode' style='text-align: right;color: #FFFFFF;margin-right: 1em;'>New Discussion</h6>");
          $(this.element).append(buttonElemet);

        }

    });

})(jQuery);

How to add and remove attribute in JQuery..

Html tag :-
<button type='submit' class='leftArrow' id='btnPost' disabled='disabled'>Post</button>

Remove attribute in jquery--
 $('#btnPost').removeAttr("disabled");

Add attribute in jquery--
 $('#btnPost').attr("disabled", "disabled");