Search code examples
javascriptmootools

MooTools Disable html elements with reference


I am using MooTools and I want to disable specific checkbox element, I tried with this code:

$$('#lbl-box-posts8 #Others').set().disabled = true;

But not working :(

My HTML Code:

<ul>
    <li id="property_type8">
        <div class="email_alert_checkbx_list_type">
            <label id="lbl-box-posts8" class="label_check c_on" for="Others">
                <input type="checkbox" value="Others" class="validate['group[1,1]'] chkBX" id="Others" name="type">Others
            </label>
        </div>
    </li>
</ul>

My Mootools Code:

JHTML::_('behavior.mootools'); /* to load mootools */
$ajax = "
    /* <![CDATA[ */
    window.addEvent('domready', function() {
            $$('#lbl-box-posts8 #Others').set().disabled = true;    
        });
    })
    /* ]]> */
    ";
$doc =&JFactory::getDocument();
$doc ->addScriptDeclaration($ajax); 

Solution

  • You mean something like this?

    $$('#lbl-box-posts8 #Others').set('disabled','disabled');