この良い例が見つからなかったのはなぜだろうか。関数内では、personはオブジェクトであり、正しい値があり、selectedPersonはグローバル変数です。\ -signsを気にしないでください、それはそれらをここに表示する方法でした。
document.getElementById(heading).innerHTML="<\p><\strong>" + selectedPerson.name+"<strong><\\p>";
これは機能しておらず、HTML内でも機能していません。
<p>
<strong>
<script>document.write(selectedPerson.name);</script>
</strong>
</p>
var selectedPerson;
function person(extra){
var extra_array=extra.split(",");
this.name=extra_array[0];
this.head=extra_array[1];
this.gValue=extra_array[2];
this.weight=extra_array[3];
alert(extra_array[0]+" "+extra_array[1]+" "+extra_array[2] +" "+extra_array[3]);
//alert(this.name" "this.head+" "+extra_array[2] +" "+extra_array[3]);
}
selectedPerson = new person(extra);
console.log("**************************extra-------------->" +extra);
そして問題は、HTML内でグローバル変数/オブジェクトをどのように使用できるかということです。ある場合は両方の方法を知りたいですか?配列を使用するとアラートは機能しますが、this.nameなどでは機能しません。HTML内で構文selectedPerson.nameを使用するにはどうすればよいですか?
ありがとうございました!サーミ人