如下DEMO 展示了为dom扩展一个myshowHtml 的方法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="jquery.js"></script>
</head>
<body>
<div class="container">
你好
</div>
<script>
(function ($) {
$.fn.myshowHtml = function(){
alert(this.html());
}
})(window.jQuery)
$(function(){
$(".container").myshowHtml();
})
</script>
</body>
</html>
转载请注明原文地址: https://ju.6miu.com/read-1302470.html