jQuery Form How to - Add input[disabled=true]








Question

We would like to know how to add input[disabled=true].

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.js'></script>
<style type='text/css'>
input.inp[disabled] {<!--from   w  w w  .  j a  v a  2 s  .  c om-->
  background: #fff000;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('<input class="inp" type="text" value="jquery" />').attr('disabled', 'disabled').appendTo('body');
});
</script>
</head>
<body>
  <input type="text" value="html" class="inp" disabled="disabled" />
</body>
</html>

The code above is rendered as follows: