A PHP Error was encountered

Severity: 8192

Message: Function mcrypt_get_iv_size() is deprecated

Filename: libraries/Encrypt.php

Line Number: 319

A PHP Error was encountered

Severity: 8192

Message: Function mcrypt_create_iv() is deprecated

Filename: libraries/Encrypt.php

Line Number: 320

A PHP Error was encountered

Severity: 8192

Message: Function mcrypt_encrypt() is deprecated

Filename: libraries/Encrypt.php

Line Number: 321

jQuery Methods, Events and Actions Explained

jQuery Methods, Events and Actions Explained
684 Reads

jQuery Methods, Events and Actions Explained

Also check our Free Video tutorial on jQuery here. Do try the assignments to test your skills.

.click();

jQuery method used to do an action when a selector is clicked. You can use this click not just on clickable tags in html(a,button) but also on any tag.

Syntax:

$(‘selector’).click(function(){//do something});

 

.change();

jQuery method used to do an action when a select box value is changed.

Syntax:

$(‘selector’).change(function(){//do an action});

 

.keypress();

jQuery method used to do an action when a key is pressed. Usually used with text boxes and textarea.

Syntax:

$(‘selector’).keypress(function(){//do some action});

 

.on();

jQuery method, which can be used for all events on a particular selector. This method is used when you dynamically change your nodes and you need to have an event working on it. More on this is explained in the class. Please check the class videos for information.

Syntax:

$(‘body’).on(‘click’,’selector’,function(){// do something});

$(‘body’).on(‘keypress’,’selector’,function(){// do something});

$(‘body’).on(‘change’,’selector’,function(){// do something});

 

.fadeIn();

jQuery method used for animation. This method hides an element with the selector specified. The element should be hidden even before we use this method. Hide it using CSS.

Syntax:

$(‘selector’).fadeIn(speed,function(){//do something after fadeIn});

Note: speed is in milliseconds, ‘slow’(200 milliseconds) or ‘fast’(600 milliseconds)

 

.fadeOut();

does the opposite of fadeIn();

Syntax:

$(‘selector’).fadeOut(speed,function(){//do something after fadeOut});



.toggle();

jQuery method combines both fadeIn and fadeOut. It will switch between fadeIn and fadeOut based on the visibility of the node.

Syntax:

$(‘selector’).toggle(speed);

 

.hide();

jQuery method used to hide that node with a selector mentioned.

Syntax:

$(‘selector’).hide(speed);

Note: speed is in milliseconds, ‘slow’(200 milliseconds) or ‘fast’(600 milliseconds)

 

.show();

jQuery method used to show that node with a selector mentioned. The node should be hidden even before we use this method. Hide it using CSS.

Syntax:

$(‘selector’).show(speed);

Note: speed is in milliseconds, ‘slow’(200 milliseconds) or ‘fast’(600 milliseconds)

 

.html();

jQuery method used to get the contents of the selector. It is used to write content to the node of the selector when a string is passed as an argument.

Syntax:

$(‘selector’).html();

$(‘selector’).html(‘put some content in the node’);

 

.remove();

jQuery method used to remove that node with a selector mentioned.

Syntax:

$(‘selector’).remove();

 

.css();

jQuery method used to get or set styles of a node.

Syntax:

$(‘selector’).css(‘property’);

$(‘selector’).css(‘property’,’value’);

 

.attr();

jQuery method used to get or set an attribute.

Syntax:

$(‘selector’).attr(‘attribute_name’);//will get the value of the attribute

$(‘selector’).attr(‘attribute_name’,’value’);//will set the value of an attribute.

 

.trigger();

jQuery method used to trigger an event.An event can be click, keypress, fadeIn etc

Syntax:

$(‘selector’).trigger(event);

 

.append();

jQuery method used to add content to the end of the node. Unlike html it does not remove the existing content.

Syntax:

$(‘selector’).append(content);

 

.prepend();

jQuery method used to add content to the start of the node.

Syntax:

$(‘selector’).prepend(content);

 

.val();

jQuery method used to get or set the value of form elements.

Syntax:

$(‘selector’).val();//get the value of associated with selector

$(‘selector’).val(some_value);//sets the value of associated with selector

 

You can find more on jQuery methods and their usage at www.jquery.com. I have listed only the one which a developer be using more often.

Please do leave your questions, comments and suggestions in the comments section below and I will duly reply.


Posted on November 19, 2014 02:01 PM by Tutoslive


Leave your Comments, Questions, Concerns, Suggestions and Opinion.