Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use jQuery to publish Weibo program

Shulou Source: shulou.com Published: 2022-06-03 18:54:08 09月28日 Update

This article mainly explains "how to use jQuery to achieve the release of Weibo programs", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use jQuery to publish Weibo programs"!

XHTML code

140 tell me what you are doing.

Content published by Demo.

XHTML is a form with an input box textarea, a publish button, a span#counter that counts the number of words entered, and an information prompt span#msg. If you submit without input, you will be prompted for input.

CSS code

H4 {height:32px; line-height:32px; font-size:18px} h4 span {float:right; font-size:32px; font-family:Georgia,serif; color:#ccc; overflow:hidden} .input {width:594px; height:58px; margin:5px 0 10px 0; padding:4px 2px; border:1px solid # aaa; font-size:12px; line-height:18px; overflow:hidden} .sub _ btn {float:right; width:94px; height:28px } # msg {color:#f30} .clear {clear:both} .saylist {margin:8px auto; padding:4px 0; border-bottom:1px dotted # d3d3d3} .saylist img {float:left; width:50px; margin:4px} .saytxt {float:right; width:530px; overflow:hidden} .saytxt p {line-height:18px} .saytxt p strong {margin-right:6px} .date {color:#999}

JQuery

First introduce the jquery library and global.js file:

What global.js has to do is:

1, user input, when the mouse leaves the input box, count the number of characters entered, and output different styles (font color) on the page according to the number of input words.

2, processing submitted data: when clicking the "release" button, display the waiting picture, submit the input data through the ajax, wait for the background processing, and output the processing results to the front-end page.

The specific code is as follows:

Function recount () {var maxlen=140; var current = maxlen-$ ('# saytxt'). Val (). Length; $('.counter') .html (current); if (currentmaxlen) {$('.counter'). Css ('color','#D40D12'); $(' input.sub_btn'). Attr ('disabled','disabled') } else $('input.sub_btn'). RemoveAttr (' disabled'); if (current)

Tags: Input content processing program different code background character data statistics font word count button user page color learning prompt output practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker Shulou Tech Info Apple Xiaomi