This article mainly introduces to you how to implement Baidu search function with js. The code is divided into html part and css folding style part. Please refer to this article for the specific implementation code. I hope it can help you.
Today we will use JS to implement Baidu search function. The code is as follows:
HTML part:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
CSS cascade Style part:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
JS part:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
The search function is implemented from Baidu’s https:// sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd="+otext.value+"&cb=houxiaowei, in this link, the value of "wd" is the value to be searched in the input box, and it will return a json object. The value of &cb is a method or function, which is used to extract the value from json and put it into li.
Related recommendations:
Bootrap and Vue implement imitation Baidu search function example
How to use Js to implement Baidu search box prompts Function
PHP uses curl to create a simple Baidu search
The above is the detailed content of Examples to explain how JS implements Baidu search function. For more information, please follow other related articles on the PHP Chinese website!