• jquery修改a标签的href链接和文字


    可以先体验一下效果:http://keleyi.com/keleyi/phtml/jquery/2.htm

    以下修改a标签的href链接和修改文字的代码:

    <script type="text/javascript" src="http:/keleyi.com/keleyi/pmedia/jquery-1.9.1.min.js"></script>

    原链接:
    <a href="http://keleyi.com" id="home_keleyi_com">柯乐义</a>

    修改a标签的href链接:
    $('#home_keleyi_com').attr('href','http://keleyi.com'); 

    修改文字:
    $("#home_keleyi_com").text('柯乐义首页');

    修改后的链接为:
    <a href="http://keleyi.com" id="home_keleyi_com">柯乐义首页</a>



    下面是完整代码:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>jquery修改链接--柯乐义</title>
    <script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery-1.9.1.min.js"></script>
    </head>
    <body>
    jquery修改a标签的href链接和文字,先点击下面链接<br />然后点击"改变"按钮,然后点点击一次下面的链接,注意两次打开页面的不同:<br />
    <a href="http://keleyi.com/a/bjac/d863921ed93d03ff.htm" id="home_keleyi_com" target="_blank">原文</a> <input type="button" value="改变" id="gb_keleyi_com" />
    <script type="text/javascript">
    $("#gb_keleyi_com").bind("click",function (){
    $('#home_keleyi_com').attr('href','http://keleyi.com'); 
    $("#home_keleyi_com").text('柯乐义首页');})
    </script>
    </body>
    </html>

    参考:http://hovertree.com/hvtart/bjae/c5a746a2d25d43b7.htm

  • 相关阅读:
    eclipse连接远程hadoop集群开发时0700问题解决方案
    螺旋线
    双曲抛物面
    双曲抛物面
    工业相机标定相关知识整理
    高科技 stuff
    高科技 stuff
    杜甫诗百首
    杜甫诗百首
    经典纪录片
  • 原文地址:https://www.cnblogs.com/xiaoleiel/p/8308827.html
Copyright © 2020-2023  润新知