420071 ランダム
 ホーム | 日記 | プロフィール 【フォローする】 【ログイン】

プログラミング好きなきょうゆうくんのブログ

プログラミング好きなきょうゆうくんのブログ

【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! --/--
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x

PR

プロフィール

きょうゆうくん

きょうゆうくん

カレンダー

バックナンバー

カテゴリ

日記/記事の投稿

コメント新着

Sownvpt@ Re:python????:ubunts?json????(02/10) Истинно полезно смотреть вперед на воз…
Sownrhe@ Re:python????:ubunts?json????(02/10) Ваша информация очень значимый. посмот…
Sownwha@ тайланд пукет билети Thanks very interesting blog! взгляни…
Sowntep@ тайланд и туристически потенциал I do consider all of the concepts you&…
Sownevk@ посолство на тайланд Heya i'm for the first time here.…

キーワードサーチ

▼キーワード検索

2024.02.04
XML
カテゴリ:javascript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <button type=”button” id="sample0" onclick=buttonText0()>クリック0</button>
    <button type=”button” id="sample1" onclick=buttonText1()>クリック1</button>
    <p id="pid0">  </p>
    <p id="pid1">  </p>
    <script>
       
        function buttonText0 () {
            var pppp = document.getElementById('pid0');
            pppp.innerHTML="<img src=\"http://snc29654.php.xdomain.jp/jpg/33.jpg\" width=\"300px\">" ;
        }

        function buttonText1 () {
            var pppp = document.getElementById('pid1');
            pppp.innerHTML="<img src=\"http://snc29654.php.xdomain.jp/jpg/1.jpg\" width=\"300px\">" ;
        }

    </script>
</body>
</html>


innerhtmlを使わなくても、以下で同じ結果となる
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <button type=”button” id="sample0" onclick=buttonText0()>クリック0</button>
    <button type=”button” id="sample1" onclick=buttonText1()>クリック1</button><br>
    <img src="" width="300px" id="pid0"><br>
    <img src="" width="300px" id="pid1">
    <script>
       
        function buttonText0 () {
            var pppp = document.getElementById('pid0');
            pppp.src="http://snc29654.php.xdomain.jp/jpg/33.jpg";
        }

        function buttonText1 () {
            var pppp = document.getElementById('pid1');
            pppp.src="http://snc29654.php.xdomain.jp/jpg/1.jpg";
        }

    </script>
</body>
</html>





お気に入りの記事を「いいね!」で応援しよう

最終更新日  2024.02.06 09:53:53
コメント(0) | コメントを書く


フリーページ

サイド自由欄


© Rakuten Group, Inc.