Bonsoir,
J'ai un bug dans un de mes scripts, je procède donc par dichotomie, et j'en arrive... à rien ! (attention, je préfère prévenir, je suis très fatigué!)
Voici un exemple récupéré sur le site jquery :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>on demo</title> <style> p { background: yellow; font-weight: bold; cursor: pointer; padding: 5px; } p.over { background: #ccc; } span { color: red; } </style> <script src="//code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <p>Click me!</p> <span></span> <script> var count = 0; $( "body" ).on( "click", "p", function() { $( this ).after( "<p>Another paragraph! " + (++count) + "</p>" ); }); </script> </body> </html>
Ca fonctionne parfaitement !
Voici le même code, sauf que la partie script je la mets dans un fichier à part :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>on demo</title> <style> p { background: yellow; font-weight: bold; cursor: pointer; padding: 5px; } p.over { background: #ccc; } span { color: red; } </style> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript" src="/js/fonctions.js"> </script> </head> <body> <p>Click me!</p> <span></span> </body> </html>
et mon fichier fonctions.js :
Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 var count = 0; $( "body" ).on( "click", "p", function() { $( this ).after( "<p>Another paragraph! " + (++count) + "</p>" ); });
Et là ça ne fonctionne plus
je suis sur que c'est tout con en plus...
Partager