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

memo

Posted at

■document.getElementById('')
Idの要素を取得(1つのみ)

■document.getElementsByName('')
nameの要素を取得(複数あり)

□radio,checkbox
nameならすべての要素を取得。
どこにチェックがついているかはfor文で回して、要素.checkedで判定。

□select
idで取得。
→optionで選択されいるものを取得する。
イベントはselectの方に書かないと発火しない。

・選択
select.lengthででoptionの数
select.selectedIndexで選択されいるoption番号を取得
select.selectedIndex = 数値;で選択を変更できる。

・オプションの操作
sel.options.lengthでoptionの数
select.options[要素番号].valueで値
select.options[要素番号].selectedで選択されているかの判定

・オプションの削除
select.innerHTML = "";
select.remove(要素番号);
1
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
    <category filters="*" id="カテゴリー_1698509025612" initial_state="0" label="Js" largeicon="" smallicon="">
        <description/>
        <item category="カテゴリー_1698509025612" class="" editorclass="" id="項目_1698509025613" label="console.log" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[console.log();...]]></description>
            <content><![CDATA[console.log();]]></content>
        </item>
        <item category="カテゴリー_1698509025612" class="" editorclass="" id="項目_1698546041451" label="Id取得" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[document.getElementById('');...]]></description>
            <content><![CDATA[document.getElementById('');]]></content>
        </item>
        <item category="カテゴリー_1698509025612" class="" editorclass="" id="項目_1698545781376" label="Name取得" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[document.getElementsByName('');...]]></description>
            <content><![CDATA[document.getElementsByName('');]]></content>
        </item>
        <item category="カテゴリー_1698509025612" class="" editorclass="" id="項目_1698545863855" label="For文" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[for (let i = 0; i < ; i++) {...]]></description>
            <content><![CDATA[for (let i = 0; i < ; i++) {
				
			}]]></content>
        </item>
        <item category="カテゴリー_1698509025612" id="項目_1698563242342" label="選択リストの追加" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[let option = document.createElement('option');...]]></description>
            <content><![CDATA[let option = document.createElement('option');
option.value = "";
option.text = "";
select.appendChild(option);]]></content>
        </item>
        <item category="カテゴリー_1698509025612" id="項目_1698578028532" label="style表示/非表示" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[.style.visibility = 'hidden';...]]></description>
            <content><![CDATA[.style.visibility = 'hidden';
.style.visibility = 'visible';]]></content>
        </item>
    </category>
</snippets>
2
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
    <category filters="*" id="カテゴリー_1698545397356" initial_state="0" label="Html-basic-" largeicon="" smallicon="">
        <description/>
        <item category="カテゴリー_1698545397356" class="" editorclass="" id="項目_1698545700496" label="実行" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[<input type="submit" value="実行">...]]></description>
            <content><![CDATA[<input type="submit" value="実行">]]></content>
        </item>
        <item category="カテゴリー_1698545397356" class="" editorclass="" id="項目_1698545479452" label="テキスト" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[<input type="text" id="text">...]]></description>
            <content><![CDATA[<input type="text" id="text">]]></content>
        </item>
        <item category="カテゴリー_1698545397356" class="" editorclass="" id="項目_1698545605358" label="選択リスト" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[<select id="select">...]]></description>
            <content><![CDATA[<select id="select">
		<option value="1"></option>
	</select>]]></content>
        </item>
        <item category="カテゴリー_1698545397356" class="" editorclass="" id="項目_1698545397357" label="ラジオ" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[<input type="radio" name="r" value="">...]]></description>
            <content><![CDATA[<input type="radio" name="r" value="">]]></content>
        </item>
        <item category="カテゴリー_1698545397356" class="" editorclass="" id="項目_1698553725648" label="チェックボックス" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
            <description><![CDATA[<input type="checkbox" name="c" value="">...]]></description>
            <content><![CDATA[<input type="checkbox" name="c" value="">]]></content>
        </item>
    </category>
</snippets>

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?