


jQuery implements the method of selecting text with the mouse to post on Sina Weibo_jquery
The example in this article describes how jQuery implements mouse-selected text to post on Sina Weibo. Share it with everyone for your reference, the details are as follows:
I recently noticed that Sina Blog has a small function, that is, when the mouse selects a piece of text, a small picture will appear. Click on this picture to send the selected content to Sina Weibo. On a whim, I wrote a demo last night to play with. Take a look, the code is super simple and not optimized. Friends who are interested can improve it themselves.
The principle is very simple, first get the mouse to select the text, then call the page provided in Sina Blog, and pass the text as a parameter.
The code is as follows:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .tooltip { width:120px; height:23px; line-height:23px; background-color:#CCCCCC; } .tooltip a { color: #333333; display: block; font-size: 12px; font-weight: bold; text-indent: 10px; } </style> <script src="jquery.min.js"></script> <script type="text/javascript"> $(function () { $("#blogContent").mouseup(function (e) { var x = 10; var y = 10; var r = ""; if (document.selection) { r = document.selection.createRange().text; } else if (window.getSelection()) { r = window.getSelection(); } if (r!= "") { var bowen = "发送到新浪微博"; var tooltip = "<div id='tooltip' class='tooltip'><a onclick=ask('"+r+"')>" + bowen + "</a></div>"; $("body").append(tooltip); $("#tooltip").css({ "top": (e.pageY + y) + "px", "left": (e.pageX + x) + "px", "position": "absolute" }).show("fast"); } }).mousedown(function () { $("#tooltip").remove(); }); }) function ask(r) { if (r != "") { window.open('http://v.t.sina.com.cn/share/share.php?searchPic=false&title='+r+'&url=http://www.nowwamagic.net&sourceUrl=http%3A%2F%2Fblog.sina.com.cn&content=utf-8&appkey=1617465124', '_blank', 'height=515, width=598, toolbar=no, menubar=no, scrollbars=auto, resizable=yes, location=no, status=yes'); } } </script> </head> <body> <div id="blogContent"> words words words words words words words words words。 </div> </body> </html>
It’s that simple, you can try it yourself. Of course, there are other operations to get the selected text. This is just a trick to call Sina's page. If you are interested, you can create your own application and implement it yourself.
Readers who are interested in more jQuery-related content can check out the special topics on this site: "JQuery drag effects and techniques summary", "jQuery extension techniques summary", "JQuery common classic special effects summary", "jQuery animation and special effects usage summary", "jquery selector usage summary" and "jQuery common plug-ins and usage Summary》
I hope this article will be helpful to everyone in jQuery programming.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This article will introduce how to turn off the thumbnail function displayed when the mouse moves the taskbar icon in Win11 system. This feature is turned on by default and displays a thumbnail of the application's current window when the user hovers the mouse pointer over an application icon on the taskbar. However, some users may find this feature less useful or disruptive to their experience and want to turn it off. Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another drawback is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. but

According to news from this website on March 31, HP recently launched a Professor1 three-mode Bluetooth mouse on JD.com, available in black and white milk tea colors, with an initial price of 99 yuan, and a deposit of 10 yuan is required. According to reports, this mouse weighs 106 grams, adopts ergonomic design, measures 127.02x79.59x51.15mm, has seven optional 4000DPI levels, is equipped with a Blue Shadow RAW3220 sensor, and uses a 650 mAh battery. It is said that it can be used on a single charge. 2 months. The mouse parameter information attached to this site is as follows:

According to news from this site on July 12, Razer today announced the launch of the Razer|Pokémon Gengar wireless mouse and mouse pad. The single product prices are 1,299 yuan and 299 yuan respectively, and the package price including the two products is 1,549 yuan. This is not the first time that Razer has launched Gengar co-branded peripheral products. In 2023, Razer launched the Gengar-style Yamata Orochi V2 gaming mouse. The two new products launched this time all use a dark purple background similar to the appearance of the Ghost, Ghost, and Gengar families. They are printed with the outlines of these three Pokémon and Poké Balls, with the character Gengar in the middle. A large, colorful image of a classic ghost-type Pokémon. This site found that the Razer|Pokémon Gengar wireless mouse is based on the previously released Viper V3 Professional Edition. Its overall weight is 55g and equipped with Razer’s second-generation FOC

Many users don't know where the files installed by their Razer drivers go. These driver files are usually installed on the system disk, which is the C drive of the computer. The specific location is in the RAZE folder under programfiles. In which folder is the Razer mouse driver located? A: In the RAZE folder under programfiles on the system C drive. Generally, the driver will be installed on the C drive, just find it according to the location. Introduction to Razer mouse driver installation method 1. After downloading the file from the official website, double-click to run the downloaded EXE file. 2. Wait for the software to load. 3. Here you can choose which driver you want to install. 4. After selecting, click "Install" in the lower right corner.

According to news from this site on August 12, VGN launched the co-branded "Elden Ring" keyboard and mouse series on August 6, including keyboards, mice and mouse pads, designed with a customized theme of Lani/Faded One. The current series of products It has been put on JD.com, priced from 99 yuan. The co-branded new product information attached to this site is as follows: VGN丨Elden Law Ring S99PRO Keyboard This keyboard uses a pure aluminum alloy shell, supplemented by a five-layer silencer structure, uses a GASKET leaf spring structure, has a single-key slotted PCB, and the original height PBT material Keycaps, aluminum alloy personalized backplane; supports three-mode connection and SMARTSPEEDX low-latency technology; connected to VHUB, it can manage multiple devices in one stop, starting at 549 yuan. VGN丨Elden French Ring F1PROMAX wireless mouse the mouse

According to news from this website on March 22, Delux launched the M900Pro wireless gaming mouse with a right-handed ergonomic shape. The first pre-sale price starts at 199 yuan. Colorful M900Pro is designed with right-handed ergonomics and is built for users with medium to large hands. It weighs 63g and is sprayed with a matte UV coating. The mouse uses the PAW3395 sensor, the original Nano receiver supports 8000Hz wireless rate of return, is equipped with Huannuo blue shell pink dot micro-movement and comes standard with an RGB charging base and anti-slip stickers. In addition, the mouse also supports functions such as LOD adjustment, full-key customization, custom ripple control, and straight line correction. It is equipped with PTFE foot pads, 1.6m paracord cord, and a built-in receiver storage compartment. This site summarizes the specific parameters of this mouse as follows: Color: black, white, red

1. Press the key combination [win+x] to open the system shortcut menu and click [Computer Management]. 2. One-time expansion: Task Scheduler Task Scheduler Library Microsoft Windows Stpm. 3. Find and disable [tmp maintenance task] on the right side of the window.

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <
