Results 1 to 6 of 6
Thread: js
Hybrid View
-
16th January 2012 18:08 #1
js
,
:
function bla(){
some source
}
..
html-a <a href=# onclick="bla('1','2','3');">...</a>
, , .
function bla(id){
for(i=1; i<4; i++) {for (j=0; j<id.length; j++){if (i == id[j]) {document.getElementById(i).style.displa y = 'block';} else {document.getElementById(i).style.displa y = 'none';}}}}
? i , j , , style.display = 'block'. , .. , , , .
.
,
edit:
, , :
Code:function toggle() { for(i=0; i<arguments.length; i++) document.getElementById(arguments[i]).style.display = (document.getElementById(arguments[i]).style.display == 'none') ? 'block' : 'none'; }
-
16th January 2012 18:19 #2Mire-x
Join Date: Apr:2005
Location: Sofia
Posts: 763
( arguments), , :
EDIT ( ): { } [ ].Code:<a href=# onclick="bla({'1','2','3'});">...</a> ... function bla(args) { for (var i=0, len=args.length; i < len; i++) { args[i] ... } }
Last edited by Tarvin; 17th January 2012 at 03:07.
(10b) || !(10b)
-
16th January 2012 18:45 #3
2 - ?
--------- 19:45 --------- : 19:34 ---------
dafuq :
Code:function bla(id){ var i; for(i=0; i<id.length; i++) {document.getElementById('result').innerHTML = i + ' element of id[i] is ' + id[i]}}Code:<a href=# onclick="bla('17','2','3','45','67','13')">bla</a>o.O1 element of id[i] is 7
-
16th January 2012 23:24 #4Registered User
Join Date: Jul:2005
Location: Sofiq
Posts: 2,798
'17' ['1', '7']Code:function bla(id){ var i; for(i=0; i<id.length; i++) {document.getElementById('result').innerHTML = i + ' element of id[i] is ' + id[i]} } <a href=# onclick="bla('17','2','3','45','67','13')">bla</a>
. js ( ).
Code:function bla(id){ for(var i=0; i<id.length; i++) {document.getElementById('result').innerHTML = i + ' element of id[i] is ' + id[i]} } <a href=# onclick="bla( [ '17', '2', '3', '45', '67', '13' ] )">bla</a>
-
17th January 2012 09:59 #5
-
17th January 2012 10:43 #6Mire-x
Join Date: Apr:2005
Location: Sofia
Posts: 763
id string, '17' ( - '2' '3', , , , "", arguments). id . , : id.length == 2, id[0] == '1', id[1] == '7'.Code:function bla(id) { ... } bla('17','2','3');
? (), id. , id, arguments.
, , . , .Code:<a href=# onclick="bla(['17','2','3','45','67','13']);">bla</a> ... function bla(id) { var args = arguments; var args = id; var argsLen = args.length; for (var i=0; i < 4; i++) { for (var j=0; j < argsLen; i++) { if (i == args[j]) { document.getElementById(i).style.display = 'block'; } else { document.getElementById(i).style.display = 'none'; } } } }(10b) || !(10b)




Reply With Quote


Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in