有兩個(gè)方法秒紧,一個(gè)是改type屬性的值燕少,一個(gè)是增加readonly屬性
1鞍陨、把type='password' 改為 type='text'势决,然后在onfocus事件中把type改為password
<input type="text" onfocus="this.type='password'">
2阻塑、給input加上readonly屬性,然后在onfocus事件中把readonly屬性移除果复。
<input type="password" readonly ?onfocus="if(this.hasAttribute('readonly')){ ?????this.removeAttribute('readonly');this.blur();this.focus();}" >
最后兩行代碼是為了適配手機(jī)版safari瀏覽器陈莽,不加的話虛擬鍵盤不會(huì)彈出來挺身。
參考鏈接:
http://www.w3.org/2000/svg
https://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag#answer-24247840