2016-08-31 7 views
-1

と属性:アクセステキスト入力は、私は次のコードを持っているのjQuery

$('.centering').click(function (e) { 
    $(".thVal").replaceWith(function() { 
     console.log(this); 
     return this.value; 
    }); 
    $('.editFields').hide(); 
}); 

をこれが与えられる次のような出力のmed:

<input class="thVal" width="2" type="text" modelbind="LicenseHolder_LegalPerson_Name" value="Test Oil AB"> 
5505094091(rad 256) 
<input class="thVal" width="2" type="text" modelbind="LicenseHolder_LegalPerson.PrimaryAddress_StreetAddress" value="Testgatan 1"> 
5505094091 
<input class="thVal" width="2" type="text" modelbind="LicenseHolder_LegalPerson_PrimaryAddress_ZipCode" value="50010"> 
5505094091(rad 256) 
<input class="thVal" width="2" type="text" modelbind="x => x_LicenseHolder_LegalPerson_PrimaryAddress_HomeTown" value="Växjö Sverige"> 
5505094091(rad 256) 
<input class="thVal" width="2" type="text" modelbind="" value="0730730037"> 

を私はconsole.log(this.value)を書くときは、入力の値が表示されます。しかし、modelbind属性の値にアクセスしたいと思います。console.log(this.modelbind)と書くと、定義されません。

どのように値にアクセスできますか?

+1

'はconsole.log($(この).ATTR( "modelbindを"))を使用する場合、それは良くなる;' – px06

+0

http://api.jquery.com/attr –

答えて

1

あなたは.attr()

console.log($(this).attr("modelbind")) 

を使用して値を取得することができますし、data-attribute

+0

Ofcourse!ハハ。ありがとうございました。 – Bryan

関連する問題