hariaspind
asked on
how to read textbox attribute through jquery and findout is it readonly
How to get the value of texbox attribute readonly and set other textbox to readyonly
The attr function: http://api.jquery.com/attr/
ASKER
I tried this .this code sets the readonly att to "true" .but the textbox is still editable.But why ?
$("#divResult").find("text area").att r('ReadOnl y', true);
$("#divResult").find("text
true isn't a boolean, but text ;). Try:
$("#divResult").find("text area").att r('ReadOnl y', 'true'); - works for me
$("#divResult").find("text
check this :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script language="javascript">
$(document).ready(function() {
$("#but").click(function() {
// get the value of the readonly textbox
var val = $("input[readonly='readonly']").val();
// set the value of the writeable textbox
$("input[readonly!='readonly'][type='text']").val(val);
// set it as readonly
$("input[readonly!='readonly'][type='text']").attr("readonly","readonly");
});
});
</script>
</head>
<body>
<input type="text" readonly="readonly" value="I'm readonly" />
<br />
<br />
<input type="text" value="you can modify my value" />
<br />
<br />
<input type="button" id="but" value="search readony and set readonly" />
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank.I got my issue fixed.