本文實例講述了JavaScript獲取表單enctype屬性的方法。分享給大家供大家參考。具體如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 <!DOCTYPE html> <html> <body> <form id="frm1" enctype="text/plain"> First name: <input type="text" name="fname" value="Donald"><br> Last name: <input type="text" name="lname" value="Duck"><br> </form> <p>Form data will be encoded as: <script> document.write(document.getElementById("frm1").enctype); </script> </p> </body> </html>運行結果如下:
1 Form data will be encoded as:text/plain