Skip to content

Commit 31b84b1

Browse files
save file
1 parent 4f864bd commit 31b84b1

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

code-dev/26-02-10/jquery-as-a-one-liner/jquery-as-a-one-liner.html

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<style>
88
body {display:flex;flex-direction:column;gap:20px}
99
#title {text-align:center}
10-
div {border:1px solid lightgray;padding:10px}
10+
section {border:1px solid lightgray;padding:10px}
1111
#links {display:flex;flex-direction:column;gap:10px;font-family:monospace;font-size:16px}
1212
</style>
1313

@@ -37,9 +37,11 @@ <h2 id=title>
3737
<hr>
3838

3939

40-
<div id=test>
41-
test
42-
</div>
40+
<section id=test>
41+
<div>
42+
test
43+
</div>
44+
</section>
4345

4446
<script>
4547
{
@@ -53,14 +55,14 @@ <h2 id=title>
5355
)}.bind(document);
5456

5557

56-
$('#test').txt=123
58+
$('#test div').txt=123
5759
console.log($('#test').txt);
58-
$('#test').style.color='red';
60+
$('#test div').style.color='red';
5961

6062
let tn=document.createTextNode('hello');
61-
$('#test').append(tn);
63+
$('#test div').append(tn);
6264

63-
let n=$('#test').cloneNode(true);
65+
let n=$('#test div').cloneNode(true);
6466
console.log(n);
6567
}
6668
</script>
@@ -69,10 +71,10 @@ <h2 id=title>
6971
<hr>
7072

7173

72-
<div id=test2>
74+
<section id=test2>
7375
test2
7476
<h3>test</h3>
75-
</div>
77+
</section>
7678

7779
<script>
7880
{
@@ -95,10 +97,10 @@ <h3>test</h3>
9597
<hr>
9698

9799

98-
<div id=test3>
100+
<section id=test3>
99101
test3
100102
<h3>test3</h3>
101-
</div>
103+
</section>
102104

103105
<script>
104106
{
@@ -123,16 +125,17 @@ <h3>test3</h3>
123125
)};
124126
$._this=test3;
125127

126-
128+
/*
127129
let clone=$('h3').clone
128130
$().append(clone);
129131
130132
let fn = e=>console.log('hello');
131133
$('h3').on.click = fn;
132134
$('h3').rem(fn);
133-
134-
135-
135+
*/
136+
137+
138+
136139
function _get(target,prop){
137140

138141
var datatype = v=>Object.prototype.toString.call(v).slice(8,-1).toLowerCase();
@@ -172,7 +175,8 @@ <h3>test3</h3>
172175
par.append(node);
173176
return;
174177
}
175-
if(name=='append'){debugger;
178+
if(name=='append'){
179+
debugger;
176180
node.append(attr.append);
177181
return;
178182
}
@@ -209,17 +213,18 @@ <h3>test3</h3>
209213

210214
}//get
211215

212-
let node = document.createElement('div');
213-
$.create = new Proxy(node,{get:_get});
216+
$.create = new Proxy({},{get:_get});
214217

215-
debugger;
216-
218+
219+
debugger;
220+
// cant use the proxy as node, fundamental limitation of this method
221+
// $().node
217222
let div=$.create.div({
218-
append : $('#test3').node,
223+
par : $('#test3').node,
219224
text : 'helloworld',
220225
style : {color:'green',fontWeight:'bold'}
221226
});
222-
console.log(div);
227+
//console.log(div);
223228

224229
}
225230
</script>
@@ -228,10 +233,10 @@ <h3>test3</h3>
228233
<hr>
229234

230235

231-
<div id=test4>
236+
<section id=test4>
232237
test4
233238
<h3>test4</h3>
234-
</div>
239+
</section>
235240

236241

237242
<script>
@@ -257,11 +262,11 @@ <h3>test4</h3>
257262

258263

259264
let $2 = $.new(test4);
260-
$2().txt='hello';
265+
$2('h3').txt='hello';
266+
267+
let $3 = $2.new($2('h3'));
261268

262-
let $3 = $2.new($2());
263269

264-
debugger;
265270
$3().txt='bye2';
266271

267272

0 commit comments

Comments
 (0)