码迷,mamicode.com
首页 > 其他好文 > 详细

在插件中得到,调用 插件的id

时间:2017-07-03 12:27:52      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:cto   meta   string   函数   jquery   log   this   script   调用   

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<button id="btn">改变</button>
<script src="js/jquery.js"></script>
<script>
//插件函数
$.fn.myplugs=function(){//this=>$("#btn")
// 目的是在插件中得到调用插件的元素
var ele=this.selector;
var elem=ele.substring(1);
console.log(ele);//#btn
console.log(elem);//btn
}
//调用插件
$(function(){
$("#btn").myplugs();
});
</script>
</body>
</html>

在插件中得到,调用 插件的id

标签:cto   meta   string   函数   jquery   log   this   script   调用   

原文地址:http://www.cnblogs.com/longailong/p/7109992.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!