Click chọn tất cả trong TextArea và textfield

Textarea:

Input TextBox:

_ Code chèn trong Textarea:
 
<script type="text/javascript">
function SelectAll(id)
{
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>
Textarea:<br>
<textarea rows="3" id="txtarea" onClick="SelectAll('txtarea');" style="width:400px" >
Click here:để chọn tất cả trong Textarea
</textarea>

_ Code chèn trong Textfield:
<script type="text/javascript">
function SelectAll(id)
{
document.getElementById(id).focus();
document.getElementById(id).select();
}
</script>

<input id="txtfld" onclick="SelectAll('txtfld');" style="width: 200px;" type="text"
 value="Click here:để chọn tất cả trong TextField" />
Bạn có thể dùng code để thử trong Test Html Code :
Share on Google Plus

About Testtem

    Blogger Comment
    Facebook Comment

0 nhận xét:

Đăng nhận xét