JQuery UI Plug-in implementation Baidu Teleprompter effect _jquery

Source: Internet
Author: User
Tags json php foreach prev

This example for you to share the jquery automatic text hint function for everyone to refer to, the specific content as follows

You need to implement dynamic additions in your project, delete the input boxes, and have text prompts inside each box.
JS section:

Automatic prompt function tip (obj) {$ (obj). AutoComplete ({minlength:0, source:function (Request, RE 
          Sponse) {//alert (' Dsada '); 
          var title = $ (' #test1 '). Val (); 
            $.ajax {url: ' hotlist.php?act=title ', type: ' Get ', DataType: ' JSON ', Data:request, Success:function (dataobj) {//Request object has only one term attribute, corresponding user input text/ /response is a function that gives the JSON data to the function after you have processed and obtained the data, so that the AutoComplete can display the list//self processing and get the data according to the data ...//var Dataobj = data; Represents the processed JSON data response (DATAOBJ); 
              Finally give the data to AutoComplete to show}, Error:function (XMLHttpRequest, Textstatus, Errorthrown) { 
              Alert (' Get information failed '); 
              alert (xmlhttprequest.status); 
              alert (xmlhttprequest.readystate); 
            alert (textstatus); 
        } 
          }); }, Focus:function (EveNT, UI) {$ (obj). val (Ui.item.title); 
        return false; 
          }, Select:function (event, UI) {//$ ("#project"). Val (Ui.item.title); 
          $ ("#project-id"). Val (ui.item.id); 
          $ (obj). val (Ui.item.title); 
          $ (obj). Prev (). Val (ui.item.id); 
        return false; 
        }). Data ("Ui-autocomplete"). _renderitem = function (UL, item) {return $ ("<li>") 
    . Append ("<a>" + item.id + "<br>" + item.title + "</a>"). APPENDTO (UL); 
  };  }

HTML:

<div class= "Control-group" > <label class= "Control-label" >* related recommendations </label> <div class= "Controls" &G 
     T <?php foreach ($listOne [' Recommend_title '] as $k => $v) {?> <div> <input type= ' hidden ' name= ' tu Ijian_id[] "value=" <?php echo $listOne [' title_id '] [$k];?> "/> <input type=" text "Name=" tuijian[] "class= "Show_goods" onkeyup= "tip (This)" value= "<?php echo $v;? > "/> <span class=" btn "onclick=" del (this); " > Delete </span> </div> }?> <p id= "project-description" ></p> <span class= "btn" id= "Add" onclick= "Add (this);" > Add </span> <script>//Add recommendation node function add (obj) {var str = "<div><in Put type= ' hidden ' name= ' tuijian_id[] '/><input type= ' text ' class= ' show_goods ' name= ' tuijian[] ' onkeyup= ' Tip ( This] '/> <span class= ' btn ' onclick= ' del (this); ' 
             > Delete </span></div> "; $ (obj). Before (StR); ///delete the currently recommended node function del (obj) {if ($ (". Show_goods"). Length <= 3) {alert (' minimum required 
         Three recommended titles '); 
         return false; 
         } else {$ (obj). Parent (). remove (); 
         $ (obj). Prev (). Prev (). remove (); 
         $ (obj). Prev (). remove (); 
          $ (obj). Remove ();  }} </script> </div> </div>

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.