How would I make a textbox, containing preexisting text, that when the user clicked within it all the text inside it would become highlighted. For example, the same way YouTube does the textboxes for the embed code on their videos. Thanks
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If I've understood your problem correctly, you could use some javascript (untested code):
<script language="JavaScript">
function selectText(textField)
{
textField.focus();
textField.select();
}
</script>
<input type="text" name="sometext" size="100" value="The Text" onClick='selectText(this);'>
You can put the script between your <head> and </head> tags.