jQuery

How to add a preloader when using the JQuery…

Usually there will be a div tag with an ID in which you will load the content. Example: <div id=”load”></div> Now in order to have a preloader displayed while the content is busy...
Ian Carnaghan
31 sec read

How do I hide and show HTML elements using…

This can be done by using the hide() and show() methods or the toggle() method. The toggle() method calls the show() method if the element is hidden and the hide()method if the element is showing. $(“selector”).hide(); $(“selector”).show(); or...
Ian Carnaghan
31 sec read

How to disable all html form elements within a…

NOTE: Please not that the prop JQuery function should be used instead of the attr function in JQuery 1.6 and higher Answer: To disable all input elements within div use the following code: $(‘#message :input’).attr(‘disabled’, true); To disable all select elements within div use...
Ian Carnaghan
21 sec read

How to find the height of you’re webpage using…

$(document).ready(function() {             var height = $('body').height();             alert(height) }); NOTE: Remember to include the JQuery library file.
Ian Carnaghan
3 sec read

How do I remove a css class from a…

The following code removes a css class and then adds another css class to a specific div tag $('#div_id').removeClass("OldClass").addClass("NewClass"); #div_id = Div Tags ID OldClass = CSS class that needs to be removed NewClass = CSS class that needs...
Ian Carnaghan
9 sec read

How to upload a file via Ajax using a…

Click here to download JQuery files Answer: Create a new file called form_upload.php  Include JQuery and the JQuery Form Plugin between the head tags in the form_upload.php file. {codecitation class=”brush: html;”} <head> <title>Ajax File Uploader</title>...
Ian Carnaghan
2 min read

How to get the value of a checked radio…

Within your JQuery code use the following line of code to get the value var radio_value = $("input:checked").val();
Ian Carnaghan
5 sec read

How to count the number of table rows within…

var countRows = $('#tableID tr').length; alert(countRows) or var countRows = $('#tableID tr').size; alert(countRows) The selector takes all rows and then counts them.
Ian Carnaghan
5 sec read

How to check if a checkbox has been checked…

The following code checks if a checkbox has been checked var checkBox = $("input:checked").val();   if(checkBox == 'on'){    alert('CHECKED!!'); }else{    alert('NOT CHECKED');...
Ian Carnaghan
9 sec read