hash"#"

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>hash</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<style type="text/css">
a{color:#000;text-decoration: none;height:30px;line-height: 30px;}
</style>
<body>
    <div class="link">
        
    </div>
</body>
<script type="text/javascript">
(function(){
    var oLink=$('.link');
    var oA=null;
    var oHtml='';
    for(var i=0;i<10;i++){
        if(i==0){
            oA=$('<a href="#target">这个链接没有跳转0'+i+'</a></br>');
        }else{
            oA=$('<a href="#">这是一个有新开新开窗口的链接'+i+'</a></br>');
        }
        oLink.append(oA);
    }

    var oA=$('a');
    oA.each(function(index,elem){
        if(!elem.hash){
            $(elem).attr('target','_blank');
        }
    });
})();
</script>
</html>

 

posted @ 2015-02-16 22:41  ollie_sk8  阅读(354)  评论(0编辑  收藏  举报