Hongmu Notes
Home Language Notes JavaScript

JavaScript

Introduction: js generally refers to JavaScript. JavaScript ("JS" for short) is a lightweight, interpreted or just-in-time compiled programming language with function priority. Although it is famous as a scripting language for developing Web pages, it is also used in many non-browser environments. JavaScript is a dynamic scripting language based on prototype programming and multi-paradigm.

How can I write a jQuery condition that stops code execution if the value is empty?

How can I write a jQuery condition that stops code execution if the value is empty? Language Notes JavaScript

You can use the conditional statement if to make a judgment. If the value of a variable or expression is empty, use the return keyword to terminate the execution of the function. For example: function myFunction() { var myVar = $('#myInput').val(); if (!myVar) { // If the value of myVar is empty, use ! …
👁 156
What does .on do in jquery? What's the use?

What does .on do in jquery? What's the use? Language Notes JavaScript

.on() is the event binding method provided by jQuery, which is used to bind one or more event handling functions on the specified DOM element. The syntax structure is as follows: $(selector).on(event, childSelector, data, handler); where event is one or more event types, such as "click", "mouseov...
👁 146
jquery clicks to copy the specified text and encapsulates multiple function calls

jquery clicks to copy the specified text and encapsulates multiple function calls Language Notes JavaScript

https://www.4s5.cn/archives/903.html In this article, I carefully explained click-to-copy, but my needs changed later! I need multiple clicks, and the specified elements are all different! So the edge needs to encapsulate the function! The encapsulated code function copyToClipboard(btnId, inputId) { $('#…
👁 177
jquery+bootstrap implements an ajax to dynamically submit data and modify the page

jquery+bootstrap implements an ajax to dynamically submit data and modify the page Language Notes JavaScript

That's the effect! Click the button to pop up a pop-up window, and then after submitting the data, return to the modified page to implement the code<!-- Modal box --> <div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden=…
👁 243
jquery ajax submits data to the backend and returns to processing

jquery ajax submits data to the backend and returns to processing Language Notes JavaScript

My requirement is that after clicking the submit button, the data of the specified input box will be sent to the backend via ajax. If the return is successful, the information of the specified input box will be modified to the text field in the returned json. If it fails, the information of the specified input box will be modified to be sorry. Implementation code $("#submit-btn").click(function() { // Get the value of the specified input element...
👁 177
jquery modify text

jquery modify text Language Notes JavaScript

When you need to use jQuery to dynamically modify the content of an HTML element, you can use jQuery's .html() or .text() method. For example, suppose you have the following HTML code: <div class="modal-body">Copied to clipboard</div>You can use the following code to dynamically modify &lt…
👁 250
jquery click to copy specified text

jquery click to copy specified text Language Notes JavaScript

A wave of realization for everyone from childhood to adulthood! Click to copy without prompting // Bind the click event to the copy button $('#copyBtn').on('click', function() { // Select the text to be copied var text = $('#inputBox').val(); // Create a temporary textarea element and set the text to its value…
👁 164
jquery selector

jquery selector Language Notes JavaScript

When the elements are at the same level, such as the following call, click the corresponding li tag, and the div tag corresponding to the same level of the li tag will display the HTML code: <ul id="open_list"> <li class="product_Level" data-fid="1"> <a>Cloud Server</a> &…
👁 158
js jump to the specified page after 5 seconds

js jump to the specified page after 5 seconds Language Notes JavaScript

Analysis: 1. If navigation is required, use the `href` attribute of the `location` object. 2. To create a 5-second countdown, use `setInterval`. HTML: `<div id= "msg"></div>` JavaScript: `window.onload=function(){...}`
👁 141
js mouse scroll automatically hides navigation menu

js mouse scroll automatically hides navigation menu Language Notes JavaScript

HTML code: <header class= "header-navigation" id= "header" > <nav> <a class= "link" href= "#" title=&qu...
👁 128
1 2 3 4