<div id="external_links">
<a href="123" >123 </a><br />
<a href="456" >456
</a>
</div>
<script>
var external_links = document.getElementById('external_links');
var links = external_links.getElementsByTagName('a');
for (var i=0;i < links.length;i++) {
var link = links.item(i);
link.onclick = function() {
return confirm('You are going to visit: ' + this.href);
};
}
</script>
jQuery 實現的相同的功能。
以下為引用的內容:
$('#external_links a').click(function() {
return confirm('You are going to visit: ' + this.href);
} );
沒有留言:
張貼留言