tags:

views:

43

answers:

3

how can i do. i have many html elements on page. after clicking on html button, i want that, my special div showed, but, other html are inactive. for example, textareas not editable, buttons are not clickable.

thanks

Forget say "SpecialDiv" also contain buttons, selects, textareas etc. they must be "abled".

+1  A: 

You need to make a separate, transparent <div> that covers the entire page.

You're probably looking for jQuery UI Dialog or jqModal.

SLaks
that will also require a hack (can't remember what it's called) to deal with the bizarre way that `<select>` elements work in IE6
Pointy
@Pointy: You're referring to the `<iframe>` hack. The examples I mentioned already do it.
SLaks
Why was this downvoted?
SLaks
+1  A: 
$('#yourDiv').show();
$('input, textarea, button').attr('disabled', 'disabled');
coreyward
Forgot "select"!
Pointy
+1  A: 

Well that's a little vague, but

function zap() {
  $('#magicDiv').show();
  $('input, button, textarea, select').attr({disabled: true});
}
function unzap() {
  $('#magicDiv').hide();
  $('input, button, textarea, select').attr({disabled: false});
}

Now if you need to worry about other things that might disable inputs, you could do this:

function zap() {
  $('#magicDiv').show();
  $('input, button, select, textarea').each(function(_, elem) {
    if (!elem.disabled) {
      $(elem).data('zapped', true).attr('disabled', true);
    }
  });
}
function unzap() {
  $('#magicDiv').hide();
  $('input, button, select, textarea').each(function(_, elem) {
    if ($(elem).data('zapped')) {
      $(elem).data('zapped', false).attr('disabled', false);
    }
  });
}
Pointy
If a button was previously disabled, this will still reenable it.
SLaks
yes that's true - I'll fix it
Pointy
sorry, i forgot tell you that, in magicDiv also contains buttons, selects, ... etc.
loviji
@loviji: You can add `.not('#magicDiv *')`. However, you should probably use a modal dialog plugin instead.
SLaks