LoginSignup
0
0

More than 5 years have passed since last update.

jQueryでフォーム要素を変更できないようにする。

Posted at

セレクトボックスの無効化は http://vinicius-stutz.github.io/jquery.selection.js/ を使用。


// 閲覧モードにする。
    if($("#viewMode").val() == 'true' ){

        console.log("閲覧モード");

        const color = 'darkblue';
        const backColor = 'lightgray';

        $("input[type='text']").attr('readonly', true);
        $("input[type='text']").css({'color':color, 'background-color':backColor});

        $("textarea").attr('disabled', true);
        $("textarea").css({'color':color, 'background-color':backColor});

        $("select").disableSelection();
        $("select").css({'color':color, 'background-color':backColor});

        $(":button").attr('disabled', true);
        $(":button").css({'color':color, 'background-color':backColor});

        $(":checkbox").attr('disabled', true);
        $(":checkbox").css({'color':color, 'background-color':backColor});
    }

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0