inputSearchObject.formプロパティ

inputSearchObject.formは、検索キーワード入力欄(type属性がsearchであるinput要素)が所属するform要素への参照を取得するプロパティ。

構文

取得

var $form = $inputElementReference.form;

戻り値

検索キーワード入力欄(type属性がsearchであるinput要素)が所属するform要素への参照。

サンプル

検索キーワード入力欄A:
検索キーワード入力欄B:

検索キーワード入力欄Aが属するform要素のid属性値:

検索キーワード入力欄Bが属するform要素のid属性値:

サンプルのソースコード

JavaScript

<script type="text/javascript">
window.onload = function () {
    document.getElementById( "sampleOutputA" ).innerHTML = document.getElementById( "sampleA" ).form.id;
    document.getElementById( "sampleOutputB" ).innerHTML = document.getElementById( "sampleB" ).form.id;
}
</script>

HTML

<div id="sampleWarp">
    <form id="sampleFormA">
        検索キーワード入力欄A:<input type="search" id="sampleA" value="A">
    </form>
    <form id="sampleFormB">
        検索キーワード入力欄B:<input type="search" id="sampleB" value="B">
    </form>
    <p>検索キーワード入力欄Aが属するform要素のid属性値:<span id="sampleOutputA"></span></p>
    <p>検索キーワード入力欄Bが属するform要素のid属性値:<span id="sampleOutputB"></span></p>
</div>

スポンサード リンク

カテゴリー: DOM, input type=search オブジェクト, JavaScript, リファレンス パーマリンク