0

I have following DIV which shows some controls:

<div id="buttonrow" class="buttonrow">
        <div class="Add" title="Add">
            <div class="AddButton">
                <input id="images" name="images" title="Add Photos" multiple="multiple" type="file">
            </div>
            <div class="AddText">
                Add
            </div>
        </div>
        <div class="Upload" title="Upload">
            <div class="UploadButton">
                <button id="start" type="submit" title="Upload Photos">
                </button>
            </div>
            <div class="UploadText">
                Upload
            </div>
        </div>
        <div class="Clear" title="Clear">
            <div class="ClearButton">
                <button id="reset" type="reset" title="Clear Photos">
                </button>
            </div>
            <div class="ClearText">
                Clear
            </div>
        </div>
        <div class="Delete" title="Delete">
            <div class="DeleteButton">
                <button id="delete" type="button" title="Delete Photos">
                </button>
            </div>
            <div class="DeleteText">
                Delete
            </div>
        </div>
        <div id="SelectAll">
            <input title="Select All Images" id="selectAllCB" type="checkbox">
        </div>
        <div id="dragandrophandler">
            Drag &amp; Drop Your Photos Here
        </div>
        <div id="ImagesCount">
        </div>
        <div id="Loading" class="Loading">
            <img alt="loading" src="../customcontrol/progress.gif">
            <div>
                Loading...</div>
        </div>
    </div>

I need to know how can I disable this entire DIV using Javascript/JQuery function?

EDIT: To disable DIV means user should not be able to interact with DIV controls. They must be in read-only state (non-clickable). I dont want to hide DIV!

1
  • Disabled a DIV, what do you mean? Maybe: $("#buttonrow").find(':input').prop('disabled',true);
    – A. Wolff
    Commented Feb 10, 2014 at 12:44

6 Answers 6

2

in Javascript, you can use:

<script lnaguage="javascript">
   document.getElementById('buttonrow').style.display='none';
</script>
4
  • I dont want to hide entire div. please see my post.
    – Azeem
    Commented Feb 10, 2014 at 13:01
  • @Nida: You can use that statement for all div by just changing the parameter of getElementById() function. It will be as per your id of that div.
    – ursitesion
    Commented Feb 10, 2014 at 13:05
  • the id is same as you used.
    – Azeem
    Commented Feb 10, 2014 at 13:09
  • if there is no ID for a Div, you should provide that. getElementById() and getElementByName() are two functions for this.
    – ursitesion
    Commented Feb 10, 2014 at 13:41
1

use:

 $("#buttonrow *").attr("disabled", "disabled").off('click');
2
  • It seems to be working. Can you tell me how to re-enable DIV by this method?
    – Azeem
    Commented Feb 10, 2014 at 12:54
  • what all elements are you trying to disable?? Commented Feb 10, 2014 at 13:31
1

Try this with .prop():

$("#buttonrow :input").prop("disabled", true);

:input will select all input elems including text, textarea, button, select etc.

0
$("button, input",$("#buttonrow")).attr("disabled", "disabled");
0

Can you please try this:

$("#buttonrow").each(function()
{
  $(this).prop('disbaled',true);
});

Hope this helps..

0
$('#buttonrow').on('click', function(){
   $(this).css({ 'opacity': 0.7 });
   return false;
})

Not the answer you're looking for? Browse other questions tagged or ask your own question.