您的位置:首页 > Web前端 > JQuery

编写一个jQuery的扩展方法(插件)

2016-08-25 11:20 627 查看

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<style type="text/css">

#a{

background: red;

}

</style>

</head>

<body>

<div id="a"></div>

</body>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

<script type="text/javascript">

jQuery.fn.extend({

setWidth:function(){

$(this).width(200);

$(this).height(300);

return this;

}

});

$("#a").setWidth();

</script>

</html>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: