<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>wrap</title>
<script type="text/javascript" src="../jquery/jquery-1.11.3.min.js"></script>
</head>
<body>
<a href="http://www.baidu.com" class="baidu">百度</a>
<a href="http://www.souhu.com" class="souhu">百度</a>
<a href="http://www.xinlang.com" class="xinlng">百度</a> <script type="text/javascript"> $(document).ready(function () {
var __attr = $("a").attr("href");//获取属性值
console.log(__attr); $("a").each(function (index, elem) {// index是索引 elem当前元素
// var num=$(elem).attr("href","www.eshenghuo365.com");//设置属性值
// var num=$(elem).attr({'href':'www.eshenghuo365.com','title':"e生活"});//设置多个属性值
// $(elem).attr("href",function(index,value){//动态设置属性 index是索引 value是当前属性值
// if(value.indexOf('souhu')){
// $(this).next().css("font-size","100px")
//
// }
// });
// $("a:odd").removeAttr("href"); //删除偶数行的属性
// $("a:even").removeAttr("href");//删除奇数行的属性
console.log($(elem).prop("className"));
// console.log(num); });
}); </script>
</body>
</html>

jquery attr()和prop()方法的使用的更多相关文章

  1. jquery attr()和prop()方法的区别

    $('').attr()返回的是html对象 $('').prop()返回的是DOM对象 attr(): attr() 方法设置或返回被选元素的属性和值. 当该方法用于返回属性值,则返回第一个匹配元素 ...

  2. jquery中dom元素的attr和prop方法的理解

    一.背景 在编写使用高版本[ jQuery 1.6 开始新增了一个方法 prop()]的jquery插件进行编写js代码的时候,经常不知道dom元素的attr和prop方法到底有什么区别?各自有什么应 ...

  3. input是否checked与使用jquery的attr或prop方法无关

    最近在项目中有这样一个需求,用户在下单时可以选择优惠券,也可取消选择,并且可以多次选择,取消. 这是一个典型的input标签checked功能,博主使用radio元素实现此需求,但是优惠券只能选中,不 ...

  4. jQuery中attr和prop方法的区别

    jQuery中attr和prop方法的区别。 http://my.oschina.net/bosscheng/blog/125833 http://www.javascript100.com/?p=8 ...

  5. jquery checkbox相关 prop方法

    jquery checkbox相关 prop方法 firefox中 checkbox属性checked="checked"已有,但复选框却不显示打钩的原因复选框绑定了click事件 ...

  6. jQuery 中 attr() 和 prop() 方法的区别

    前几天,有人给 Multiple Select 插件 提了问题: setSelects doesn't work in Firefox when using jquery 1.9.0 一直都在用 jQ ...

  7. jQuery 中 attr() 和 prop() 方法的区别<转>

    前几天,有人给 Multiple Select 插件 提了问题: setSelects doesn't work in Firefox when using jquery 1.9.0 一直都在用 jQ ...

  8. jQuery中attr和prop方法的区别说明

    jquery中attr和prop的基本区别可以理解为:如果是内置属性,建议用prop,如果是自定义的建议用attr. 例如 <input type=check  node=123 id=ck & ...

  9. [jQuery]attr和prop的区别

    转自:http://www.cnblogs.com/Showshare/p/different-between-attr-and-prop.html 在高版本的jquery引入prop方法后,什么时候 ...

随机推荐

  1. poj 2567 Code the Tree 河南第七届省赛

    Code the Tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2350   Accepted: 906 Desc ...

  2. stdlib

    system(pause): int cmp(const void *a ,const void *b) { return *(int *)a - *(int *)b ;          //从小到 ...

  3. linux操作系统的分类及解释

    什么是Linux? 也许很多人会不屑的说,Linux不就是个操作系统么.错!Linux不是一个操作系统,严格来讲,Linux只是一个操作系统中的内核.内核是什么?内核建立了计算机软件与硬件之间通讯的平 ...

  4. Build常见错误

    1.ant 解决com.sun.tools.javac.Main is not on the classpath的问题 在ant打包时报错: 解决com.sun.tools.javac.Main is ...

  5. Java注解处理器--annotation学习四

    Java中的注解(Annotation)是一个很神奇的东西,特别现在有很多Android库都是使用注解的方式来实现的.一直想详细了解一下其中的原理.很有幸阅读到一篇详细解释编写注解处理器的文章.本文的 ...

  6. transactionCurrencyId needs to be supplied to format a transaction money field.

    问题背景: 在CRM 4 表单中加入了自定义的,money类型的字段,如果就报错 解决方法:要显示金额类型的字段时,要保证 entity 的 TransactionCurrencyId 这个字段中是有 ...

  7. delphi SPCOMM 接收数据不完整!该如何解决

    SPCOMM 接收数据不完整!该如何解决   SPCOMM 接收数据不完整!我作了一个 读取地磅数据的程序,是用spcomm接收的! 总共有五台地磅,其他4台地磅数据读取都正常.但是有一台接收数据的时 ...

  8. 【转】Python处理HTML转义字符

    Python处理HTML转义字符 转 [http://www.cnblogs.com/xuxn/archive/2011/08/12/parse-html-escape-characters-in-p ...

  9. turing 项目引用

    1.友盟自动更新 2.友盟统计 3.友盟消息推送 http://www.bejson.com/json2javapojo/ 引用bejson 解析JSON生成类,数组 private List< ...

  10. nyoj 54-小明的存钱计划

    点击打开链接 小明的存钱计划 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 小明的零花钱一直都是自己管理.每个月的月初妈妈给小明300元钱,小明会预算这个月的花销,并且 ...