Home>

There are two buttons, search and send.
Initially, only search is active, send is deactivated, and I am thinking of activating the send button only when searching with search.

The buttons are as follows.

send

jQuery has the following settings.

Clicking the search button with this setting does not respond at all.
By the way,
$('# send_button'). removeAttr ('disabled');
If so, it will be activated for a moment, but it will soon become inactive.

Also,
var result = $('# send_button'). prop ('disabled', false);
alert (result);
Then, it was written somewhere that false was displayed, but [object Object] is displayed.

Could you please tell me the cause and solution?
I look forward to working with you.

  • Answer # 1

    Initially, only search is active, send is inactive, and

    With the current code, even in the early dayssendIs not inactive, isn't it?
    Click to/ sendIt will transition to.

    The cause is due to the HTML specifications.aThe element isdisable disableI think it's because the attributes don't work.
    https://developer.mozilla.org/ja/docs/Web/HTML/Element/a

    aAs a way to prevent tags from being clicked
    CSSpointer-events: noneuse
    There seems to be.

    send
    a.disabled {
      pointer-events: none;
    }

    However, if this is left as it is, by keyboard operation (TAB key or Enter key)aBecause you can press the elementtabindexUse attributes to suppress it.

    send

    When activatingdisabledDelete the class,tabindexAttribute value0You can change it to.

    $('# search_button'). click (function () {
        $('# send_button'). removeClass ('disabled'). Attr ('tabindex', 0);
    });

    By the way,
    $('# send_button'). removeAttr ('disabled');
    If so, it will be activated for a moment, but it will soon become inactive.

    This phenomenon did not reproduce in my environment.

    var result = $('# send_button'). prop ('disabled', false);
    alert (result);
    Then, it was written somewhere that false was displayed, but [object Object] is displayed.

    I think that's correct.prop ('disabled', false)Should return a jQuery object.