var js = "alert('B:' + this.id); return false;";
// creates a function from the "js" string
var newclick = eval("(function(){"+js+"});");
// clears onclick then sets click
$("#anchor").attr('onclick', '').click(newclick);

转自:http://www.cnblogs.com/dudu/archive/2010/02/27/1674690.html

[转载]通过jQuery的attr修改onclick的更多相关文章

  1. 通过jQuery的attr修改onclick值的的解决方法

    好了,直接给大家贴上js代码吧 var js = "alert('B:' + this.id); return false;"; var newclick = eval(" ...

  2. 通过jQuery的attr修改onclick

    var js = "alert('B:' + this.id); return false;"; // creates a function from the "js&q ...

  3. jquery 用attr修改src 淡入淡出

    $("#wanwan").animate({ opacity: 'toggle' }, "slow", null, function () { $(" ...

  4. 使用jQuery的attr方法来修改onclick值

    这篇文章主要介绍了通过jQuery的attr修改onclick值的解决方法 ,需要的朋友可以参考下 var js = "alert('B:' + this.id); return false ...

  5. jQuery attr方法修改onclick值

    了通过jQuery的attr修改onclick值. 代码: var js = "alert('B:' + this.id); return false;"; var newclic ...

  6. jQuery.fn.attr与jQuery.fn.prop

    jQuery.fn.attr与jQuery.fn.prop jQuery.fn.attr.jQuery.fn.prop的区别 假设页面有下面这么个标签,$('#ddd').attr('nick').$ ...

  7. jQuery源码-jQuery.fn.attr与jQuery.fn.prop

    jQuery.fn.attr.jQuery.fn.prop的区别 假设页面有下面这么个标签,$('#ddd').attr('nick').$('#ddd').prop('nick')分别会取得什么值? ...

  8. jquery中attr和prop的区别(转)

    在网络上看到这样一篇关于jquery中attr和prop的区别文章,觉得不错,所以转载了. 在jQuery 1.6中,.attr()方法查询那些没有设置的属性,则会返回一个undefined.如果你要 ...

  9. 对jquery的 attr()和prop()理解

    jquery1.6版本后引入了prop()方法,很多时候总是混淆attr()与prop()这俩,下面分析一下这俩的区别 在此之前,先来了解一下html 的attribute和property,因为jq ...

随机推荐

  1. HDU 3006 The Number of set(位运算 状态压缩)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3006 题目大意:给定n个集合,每个集合都是由大于等于1小于等于m的数字组成,m最大为14.由给出的集合 ...

  2. php返回相对时间(如:20分钟前,3天前)的方法

    function plural($num) { if ($num != 1) return "s"; } function getRelativeTime($date) { $di ...

  3. [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法

    最近把一个项目的jQuery升级到最新版,发现有些页面报错Cannot read property ‘msie’ of undefined.上jQuery网站上搜了一下,原因是$.browser这个a ...

  4. mysql的字段类型范围必须重视起来

    在MySQL数据类型中,例如INT,FLOAT,DOUBLE,CHAR,DECIMAL等,它们都有各自的作用,下面我们就主要来介绍一下MySQL数据类型中的DECIMAL类型的作用和用法. 一般赋予浮 ...

  5. Android Thread和AsyncTask

    1. 线程Thread 2. 异步任务AsyncTask ------------------------------------------------- --------------------- ...

  6. QFTP走了以后QNetworkAccessManager出现了

    QNetworkAccessManager Class Header:    #include <QNetworkAccessManager>qmake:     QT += networ ...

  7. linux安装python使用的MySQLdb

    安装mysqldb模块需已安装mysql 使用pip安装MySQLdb pip install mysql-python mac os安装mysqldb sudo pip install mysql- ...

  8. 无Xaml的WPF展示

    我们创建一个wpf应用程序,我们把里面的xaml文件全部删除,添加一个新类: 如下图: 然后我们cs文件中的代码: using System; using System.Collections.Gen ...

  9. SecurityCRT输出日志重定向

    使用CRT进行抓取log,因为工具本省缓冲区有限,导致,刷屏特别快,可能会错过一些log,可以对CRT的log进行增加输出源,或者说将输出到控制台的log再输出到本地文件中: 文件->点击(勾选 ...

  10. 写个自动下载安装Ant的shell脚本【一】

    #!/bin/bash ###################################################### # file name: install_ant.sh # # f ...