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

<!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>
posted @ 2017-07-03 10:46  Ai-Long  阅读(446)  评论(0编辑  收藏  举报