[英]How to make a text input field “readonly” using javascript / html?
我想自定義我的 Jira,需要在 javascript / html 中將文本輸入字段設置為只讀。 我已經得到了以下代碼,它在我的自定義字段“摘要”中設置了一個默認值:
window.ATL_JQ_PAGE_PROPS = $.extend(window.ATL_JQ_PAGE_PROPS, {
triggerFunction: function(showCollectorDialog) {
$('#feedback-button').on( 'click', function(e) {
e.preventDefault();
showCollectorDialog();
});
},
fieldValues: {
summary : 'Solution'
}
});
</script>
下一步是將“摘要”設置為只讀,這樣用戶就不能再修改我的預定義標題了。 我已經嘗試過“document.getElementById("summary").setAttribute("readonly", true);" 和類似的東西,但沒有成功。 也許我做錯了什么,因為我不是程序員,有人有建議嗎?
提前致謝
<input type="text" value="static value" readonly>
您可以使用只讀屬性執行此操作,它可以防止所有類型的更改
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.