比如:
<p>
<a herf="" id="abc">123456789</a>
</p> 如果选中123456话 就获得 <a> 中id的值 "abc"
<p>
<a herf="" id="abc">123456789</a>
</p> 如果选中123456话 就获得 <a> 中id的值 "abc"
<a herf="javascript:alert(this.id);" id="abc" >123456789</a>
</p>
<p>
<a herf="javascript:;" onclick="alert(this.id)" id="abc" >123456789</a>
</p>
<html>
<table border='1'>
<tr>
<td>
<a herf="" id="abc" onclick='getId(this.id)'>123456789</a>
</td>
</tr>
</table>
<script>
function getId(id){
alert("id="+id);
}
</script>
</html>
<p>
<a herf="" id="abc" onselectstart="test(this)">123456789</a>
</p>function test(obj){
alert(obj.id)
}
<div align="center"><BR>
<textarea name="yourForm" rows=3 cols=40 wrap=virtual>
<BR>这里是测试文本......</textarea><BR>
<input type=button value="选中所有内容" onClick="javascript:this.form.yourForm.focus();this.form.yourForm.select();"><BR>
</div><BR>
</form>
<p>
<a herf="" onmousedown="this.focus();" onmouseup="a(this);" id="abc">123456789</a>
</p>
<p>
<a herf="" onmousedown="this.focus();" onmouseup="a(this);" id="ee">123456789</a>
</p><script type="text/javascript">
function a(_this){
var t = document.all?_this.ownerDocument.selection.createRange().text:_this.ownerDocument.getSelection();
if(t)
alert(_this.id);
}
</script>