-1

I have a page that will cause an error if a user tries to click too many buttons at one time (for the impatient user) and therefore need to DISable any button (all defined by a JS onclick function) on the page until it is refreshed (with new data sent via the server using Java.) What is the best method to do this, and is there a way to do it with jQuery?

4

3 回答 3

1

How about simply calling this when you want to disable the buttons:

jQuery('input[type="button"]').attr('disabled', 'disabled');

That will disable all inputs of type button on the page. Of course, as soon as you reload/replace the page contents, the new buttons will not be disabled. You can also just disable all inputs if that's easier.

Fiddle: http://jsfiddle.net/duffmaster33/xDMux/

于 2013-05-15T15:53:22.693 回答
1

You would have to find all types of buttons using something like this..

$('input[type="submit"], button')

and loop through the returned array and do .attr('disabled','disabled'); on the item in each iteration.

于 2013-05-15T15:54:41.153 回答
1

The single best solution is to use the BlockUI plugin for jQuery. It accomplished everything I needed and more. http://www.malsup.com/jquery/block/

于 2013-06-14T13:41:48.043 回答