$('body').prepend('<div id='nav' class='navbar'><div class='navbar-content'><a href='/' class='element'><span class='icon-grid-view'></span> 后台管理 <sup>1.0 Beta</sup></a> <span class='element-divider'></span> <a class='pull-menu' href='#'></a><div class='no-tablet-portrait'><div class='element place-right'><a class='dropdown-toggle' href='#'><span id='spanUser'>刁静?2</span><span class='icon-user-2'></span></a><ul class='dropdown-menu place-right' data-role='dropdown'><li><a href='#'>密码修改</a></li></ul></div><span class='element-divider place-right'></span></div></div></div>');
Copy after login
For the same piece of code, if I write this js directly on the page, it is absolutely fine. But if I write it in a js file (this js file was introduced later than the UI framework js), this code only renders the style, but the event has no effect at all.
For example, in the picture, after clicking on the user, a drop-down menu will pop up.
If js is written in the page, click "↓" and the "Change Password" menu will pop up
But if js is written in a separate js file, and then import this js file, click "↓" and nothing will happen reflect.
What could be causing this?
Reply to discussion (solution)
This depends on the loading order of js files
This js file was introduced later than the UI framework js)
In this way, you will miss the initialization event in the framework code
this js files were introduced later than the UI framework js)
In this way, you miss the initialization event in the framework code
I don’t understand it at all
<link href="css/UI.css" rel="stylesheet" /> <script src="js/UI.js"></script><body></body><script type="text/javascript">$("body").append()</script>
Copy after login
Now you can write it like this, and then I will change the
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31