[英]How to create a CSS class to make input field is readonly
我想創建一個CSS類以使輸入字段為只讀。
這是我的嘗試:
<style>
.enableInput input[readonly] {
color: #CB000F;
}
</style>
<script>
function changeCss()
{
$("#desg").addClass("enableInput input");
}
</script>
</head>
FirstName:<input type="text" name='fname' id='fname' onBlur="changeCss();">
Designation:<input type="text" name='desg' id='desg' value='Software Engr'>
</html>
你只能在jQuery中做到
function changeCss()
{
$('#desg').prop('disabled', true);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.