jQuery Archives - Ian Carnaghan

How to add a preloader when using the JQuery ajax load method

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...

Mar 21 · 31 sec read >

How do I hide and show HTML elements using JQuery without any special effects?

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...

Mar 21 · 31 sec read >

How to disable all html form elements within a DIV tag using JQuery

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:...

Mar 21 · 21 sec read >

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

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

Mar 21 · 3 sec read >

How do I remove a css class from a div tag and then add another css class to that same div tag using JQuery?

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...

Mar 21 · 9 sec read >

How to upload a file via Ajax using a form with JQuery and PHP

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:...

Mar 21 · 2 min read >

How to get the value of a checked radio button in a group using JQuery

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

Mar 21 · 5 sec read >

How to count the number of table rows within an html table using JQuery

var countRows = $('#tableID tr').length; alert(countRows) or var countRows = $('#tableID tr').size; alert(countRows) The selector takes all rows and...

Mar 21 · 5 sec read >

How to check if a checkbox has been checked using JQuery

The following code checks if a checkbox has been checked var checkBox = $("input:checked").val();   if(checkBox == 'on'){   ...

Mar 21 · 9 sec read >