[英]selecting field text with javascript
I am using the below code to select a fields text with JavaScript but it doesn't quite work: 我正在使用下面的代码通过JavaScript选择字段文本,但效果不佳:
//auto select that fields text for easy COPY
var content = parent.document.getElementById('share_field_<?php echo $id; ?>');
content.focus();
content.select();
Field to select: 要选择的字段:
//share field //分享栏位
echo '<div class="name" style="display: none" id="share_field_'.$row['id'].'"><input name="share" type="text" value="http://www.site.com/play/'.$row['id'].'" size="53"></div>';
I think you should use something like this: 我认为您应该使用以下方式:
var content = parent.document.getElementById('share_field_<?php echo $id; ?>');
content.firstChild.focus();
content.firstChild.select();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.