<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>封装JQuery方法</title>
</head>
<span id="aa">aaaaaaa</span>
<body>
</body>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$.fn.myPlugin = function (options) {
$options = $.extend({
html: "no messages",
css: {
"color": "red",
"font-size": "14px"
}
},
options);
return $(this).css({
"color": $options.css.color,
}).html($options.html);
}
console.log($('#aa').val());
$('#aa').myPlugin({ html: "So easy,yes?", css: { "color": "green", "font-size": "20px" } });
</script>
</html>
封装JQuery方法
最新推荐文章于 2024-06-02 21:27:33 发布