1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

bootstrap4のテンプレートを使ってjqueryの簡易テスト

Last updated at Posted at 2021-11-17

初心者の強い味方、BootstrapはjQueryを使い始めた初心者には強い味方。

functionで画面操作をひとまとめにするのってどうやるんだっけ?
簡易に確認したいけど、すぐ実装ってのもなぁ・・・
というわけで、テスト用にコピペで出来るbootstrap4を使って確認してみました。

bootstrap4のテンプレートなら楽にテストができるかなと思い実行してみた。

See the Pen Untitled by kyo07 (@kyo07) on CodePen.

#参考ページ
https://getbootstrap.jp/docs/4.3/getting-started/introduction/

html

<!doctype html>
<html lang="ja">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <title>Jquery初心者用テストテンプレート</title>
  </head>
  <body>
<!--追記開始-->
      <div>
    <h1>Jquery初心者用テストテンプレート</h1>
    <p>id=test1 <input id="test1" var=""></p>
    <p>テスト1の値が1以外のとき確認後にtest2に値が入る<br>テスト1が1のときそのままtest2に値が入る</p>
    <p>id=test2 <input id="test2" var=""></p>
    </div>
<!--追記終了-->
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    <script>
//テストしたいjsのコードをここに入れる。
$('#test1').on('change', function () {
    var test10 = function() {
        sucsess = "sucsess";
        $('#test2').val(sucsess);
    };
    var test11 = function() {
        comment = "やーん";
        $('#test2').val(comment) ;
    };
    if($('#test1').val() == 1){
        test10();
    }else if(confirm("test")){
        test11();
    }
});
    </script>
</body>
</html>

#コードペンの参考
https://qiita.com/fumu238/items/f73274aa1a188eb15794

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?