SoFunction
Updated on 2025-02-28

Stay away from JS disaster CSS disaster JS private functions and css selectors as containers


<html xmlns="http:///1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4." type="text/javascript"></script>
<script type="text/javascript">
var publicSetDiv = function (url, id) {
//As a public one, you can just pass it on to the public
= function (j) {
var imglist = makeimglist(url, j);
$(id).html(imglist);
$(id).show();
}
//Private
function makeimglist(url, j) {
var i = 0;
//var j = 10;
var html = "";
for (i; i < j; i++) {
html += "<img src='" + url + "' class='item' />";
}
return html;
}
}
$(document).ready(function () {
// Handler for .ready() called.
var mytest = new publicSetDiv("/logo_small.gif", "#test");
(10);
var mytest2 = new publicSetDiv("/logo_small.gif", "#test2");
(10);
});
</script>
<%-- Original default style-%>
<style type="text/css">
.item{ width:200px; height:100px; }
#test2 .item{ width:200px; height:100px; }
</style>
<%-- Use this style for the second time and make a slight modification --%>
<style type="text/css">
#test2 .item{ width:200px; height:200px; background-color:Black; }
</style>
</head>
<body>
<form runat="server">
First time use
<div style=" display:none;">
</div>
<div style=" display:none;">
</div>
</form>
</body>
</html>