{"id":217856,"date":"2022-09-06T19:27:27","date_gmt":"2022-09-06T11:27:27","guid":{"rendered":"https:\/\/www.8baidu.cc\/217856.html"},"modified":"2022-09-06T19:27:27","modified_gmt":"2022-09-06T11:27:27","slug":"jquery-button-%e4%ba%8b%e4%bb%b6%e7%bb%91%e5%ae%9a-button%e7%bb%91%e5%ae%9a%e7%82%b9%e5%87%bb%e4%ba%8b%e4%bb%b6%e7%82%b9%e5%87%bb%e6%b2%a1%e5%8f%8d%e5%ba%94","status":"publish","type":"post","link":"https:\/\/www.dongwubaike.cn\/fanhao\/217856.html","title":{"rendered":"jquery button \u4e8b\u4ef6\u7ed1\u5b9a  button\u7ed1\u5b9a\u70b9\u51fb\u4e8b\u4ef6\u70b9\u51fb\u6ca1\u53cd\u5e94"},"content":{"rendered":"<p>button\u4e8b\u4ef6\u7ed1\u5b9a\u5728\u4e00\u8d77\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4f7f\u7528\u5b83\u4eec\u6765\u6267\u884c\u4efb\u52a1\u3002\u5982\u679c\u4f60\u4e0d\u77e5\u9053\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u793a\u4f8b\u6765\u5b66\u4e60\u3002\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u7c7b\uff0c\u8be5\u7c7b\u5305\u542b\u4e24\u4e2a *** \uff0c\u5206\u522b\u7528\u4e8e\u521b\u5efa\u548c<\/p>\n<p><\/p>\n<h3>\u4e00\uff1ajquery\u7ed9button\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6<\/h3>\n<p>\u9996\u5148\u4f7f\u7528jQuery\u9009\u62e9\u5668\u83b7\u53d6\u5230\u60f3\u8981\u7ed1\u5b9aclick\u4e8b\u4ef6\u7684img\u5143\u7d20\uff0c\u7136\u540e\u53ef\u4ee5\u76f4\u63a5\u7ed1\u5b9aclick *** \uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7bind *** \u7ed1\u5b9a\u3002\u8fd9\u91cc\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e0bbind *** \u3002jQuery \u4e8b\u4ef6 &#8211; bind()  ***  \u2014\u2014 \u5b9a\u4e49\u548c\u7528\u6cd5<\/p>\n<p>html\u4e2d\u5982\u4f55\u7ed9\u56fe\u7247\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6\u7684\u8be6\u89e3<\/p>\n<p>bind()  *** \u4e3a\u88ab\u9009\u5143\u7d20\u6dfb\u52a0\u4e00\u4e2a\u6216\u591a\u4e2a\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\uff0c\u5e76\u89c4\u5b9a\u4e8b\u4ef6\u53d1\u751f\u65f6\u8fd0\u884c\u7684\u51fd\u6570\u3002<\/p>\n<p>jQuery \u4e8b\u4ef6 &#8211; bind()  ***  \u2014\u2014\u5c06\u4e8b\u4ef6\u548c\u51fd\u6570\u7ed1\u5b9a\u5230\u5143\u7d20<\/p>\n<p>\u89c4\u5b9a\u5411\u88ab\u9009\u5143\u7d20\u6dfb\u52a0\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\uff0c\u4ee5\u53ca\u5f53\u4e8b\u4ef6\u53d1\u751f\u65f6\u8fd0\u884c\u7684\u51fd\u6570\u3002<\/p>\n<p>jQuery \u4e8b\u4ef6 &#8211; bind()  *** \u2014\u2014\u8bed\u6cd5<\/p>\n<p>1 $(selector).bind(event,data,function)<\/p>\n<p>jQuery \u4e8b\u4ef6 &#8211; bind()  *** \u2014\u2014\u53c2\u6570\u63cf\u8ff0<\/p>\n<p>event \u5fc5\u9700\u3002\u89c4\u5b9a\u6dfb\u52a0\u5230\u5143\u7d20\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u4e8b\u4ef6\u3002\u7531\u7a7a\u683c\u5206\u9694\u591a\u4e2a\u4e8b\u4ef6\u3002\u5fc5\u987b\u662f\u6709\u6548\u7684\u4e8b\u4ef6\u3002<\/p>\n<p>data \u53ef\u9009\u3002\u89c4\u5b9a\u4f20\u9012\u5230\u51fd\u6570\u7684\u989d\u5916\u6570\u636e\u3002<\/p>\n<p>function \u5fc5\u9700\u3002\u89c4\u5b9a\u5f53\u4e8b\u4ef6\u53d1\u751f\u65f6\u8fd0\u884c\u7684\u51fd\u6570\u3002<\/p>\n<p>\u5b9e\u4f8b\uff1a<\/p>\n<p>1 \/\/\u76f4\u63a5\u7ed9\u6240\u6709img\u6807\u7b7e\u7ed1\u5b9aclick\u4e8b\u4ef6<\/p>\n<p>2 $(&#8220;img&#8221;).click(function(){<\/p>\n<p>3 alert(&#8216;\u4f60\u70b9\u51fb\u4e86\u56fe\u7247&#8217;);<\/p>\n<p>4 })<\/p>\n<p>5 <\/p>\n<p>6 \/\/\u4f7f\u7528bind *** \u7ed1\u5b9aclick\u4e8b\u4ef6<\/p>\n<p>7 $(&#8220;img&#8221;).bind(&#8220;click&#8221;,function(){<\/p>\n<p>8 alert(&#8216;\u4f60\u70b9\u51fb\u4e86\u56fe\u7247&#8217;);<\/p>\n<p>9 })<\/p>\n<p>Html \u7684img\u6807\u7b7e\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6<\/p>\n<p>1 package com.topnews;<\/p>\n<p>2 <\/p>\n<p>3 import java.util.ArrayList;<\/p>\n<p>4 <\/p>\n<p>5 import android.annotation.SuppressLint;<\/p>\n<p>6 import android.app.Activity;<\/p>\n<p>7 import android.app.Fragment;<\/p>\n<p>8 import android.content.Context;<\/p>\n<p>9 import android.content.Intent;<\/p>\n<p>10 import android.graphics.Bitmap;<\/p>\n<p>11 import android.os.AsyncTask;<\/p>\n<p>12 import android.os.Bundle;<\/p>\n<p>13 import android.text.TextUtils;<\/p>\n<p>14 import android.util.Log;<\/p>\n<p>15 import android.view.View;<\/p>\n<p>16 import android.view.ViewGroup.LayoutParams;<\/p>\n<p>17 import android.webkit.WebChromeClient;<\/p>\n<p>18 import android.webkit.WebSettings;<\/p>\n<p>19 import android.webkit.WebView;<\/p>\n<p>20 import android.webkit.WebViewClient;<\/p>\n<p>21 import android.webkit.WebSettings.LayoutAlgorithm;<\/p>\n<p>22 import android.widget.Button;<\/p>\n<p>23 import android.widget.FrameLayout;<\/p>\n<p>24 import android.widget.ProgressBar;<\/p>\n<p>25 import android.widget.TextView;<\/p>\n<p>26 <\/p>\n<p>27 import com.topnews.base.BaseActivity;<\/p>\n<p>28 import com.topnews.bean.NewsEntity;<\/p>\n<p>29 import com.topnews.service.NewsDetailsService;<\/p>\n<p>30 import com.topnews.tool.BaseTools;<\/p>\n<p>31 import com.topnews.tool.DataTools;<\/p>\n<p>32 import com.topnews.tool.DateTools;<\/p>\n<p>33 <\/p>\n<p>34 @SuppressLint(&#8220;JavascriptInterface&#8221;)<\/p>\n<p>35 public class DetailsActivity extends BaseActivity {<\/p>\n<p>36 private TextView title;<\/p>\n<p>37 private ProgressBar progressBar;<\/p>\n<p>38 private FrameLayout customview_layout;<\/p>\n<p>39 private String news_url;<\/p>\n<p>40 private String news_title;<\/p>\n<p>41 private String news_source;<\/p>\n<p>42 private String news_date;<\/p>\n<p>43 private NewsEntity news;<\/p>\n<p>44 private TextView action_comment_count;<\/p>\n<p>45 WebView webView;<\/p>\n<p>46 <\/p>\n<p>47 @Override<\/p>\n<p>48 protected void onCreate(Bundle savedInstanceState) {<\/p>\n<p>49 \/\/ TODO Auto-generated method stub<\/p>\n<p>50 super.onCreate(savedInstanceState);<\/p>\n<p>51 setContentView(R.layout.details);<\/p>\n<p>52 setNeedBackGesture(true);\/\/ \u8bbe\u7f6e\u9700\u8981\u624b\u52bf\u76d1\u542c<\/p>\n<p>53 getData();<\/p>\n<p>54 initView();<\/p>\n<p>55 initWebView();<\/p>\n<p>56 }<\/p>\n<p>57 <\/p>\n<p>58 \/* \u83b7\u53d6\u4f20\u9012\u8fc7\u6765\u7684\u6570\u636e *\/<\/p>\n<p>59 private void getData() {<\/p>\n<p>60 news = (NewsEntity) getIntent().getSerializableExtra(&#8220;news&#8221;);<\/p>\n<p>61 news_url = news.getSource_url();<\/p>\n<p>62 news_title = news.getTitle();<\/p>\n<p>63 news_source = news.getSource();<\/p>\n<p>64 news_date = 65DateTools.getNewsDetailsDate(String.valueOf(news.getPublishTime()));<\/p>\n<p>66 }<\/p>\n<p>67 <\/p>\n<p>68 private void initWebView() {<\/p>\n<p>69 webView = (WebView) findViewById(R.id.wb_details);<\/p>\n<p>70 LayoutParams params = new 71LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);<\/p>\n<p>72 if (!TextUtils.isEmpty(news_url)) {<\/p>\n<p>73 WebSettings settings = webView.getSettings();<\/p>\n<p>74 settings.setJavaScriptEnabled(true);\/\/ \u8bbe\u7f6e\u53ef\u4ee5\u8fd0\u884cJS\u811a\u672c<\/p>\n<p>75 \/\/ settings.setTextZoom(120);\/\/Sets the text zoom of the page in<\/p>\n<p>76 \/\/ percent. The default is 100.<\/p>\n<p>77 settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);<\/p>\n<p> 78 \/\/ settings.setUseWideViewPort(true); \/\/\u6253\u5f00\u9875\u9762\u65f6\uff0c \u81ea\u9002\u5e94\u5c4f\u5e55<\/p>\n<p>79 \/\/ settings.setLoadWithOverviewMode(true);\/\/\u6253\u5f00\u9875\u9762\u65f6\uff0c \u81ea\u9002\u5e94\u5c4f\u5e55<\/p>\n<p>80 settings.setSupportZoom(false);\/\/ \u7528\u4e8e\u8bbe\u7f6ewebview\u653e\u5927<\/p>\n<p>81 settings.setBuiltInZoomControls(false);<\/p>\n<p>82 webView.setBackgroundResource(R.color.transparent);<\/p>\n<p>83 \/\/ \u6dfb\u52a0js\u4ea4\u4e92\u63a5\u53e3\u7c7b\uff0c\u5e76\u8d77\u522b\u540d imagelistner<\/p>\n<p>84 webView.addJavascriptInterface(new 85JavascriptInterface(getApplicationContext()), &#8220;imagelistner&#8221;);<\/p>\n<p>86 webView.setWebChromeClient(new MyWebChromeClient());<\/p>\n<p>87 webView.setWebViewClient(new MyWebViewClient());<\/p>\n<p>88 Log.i(&#8220;info&#8221;, &#8220;news_url:&#8221; + news_url);<\/p>\n<p>89 Log.i(&#8220;info&#8221;, &#8220;news_title:&#8221; + news_title);<\/p>\n<p>90 Log.i(&#8220;info&#8221;, &#8220;news_source:&#8221; + news_source);<\/p>\n<p>91 Log.i(&#8220;info&#8221;, &#8220;news_date:&#8221; + news_date);<\/p>\n<p>92 new MyAsnycTask().execute(news_url, news_title, news_source + &#8221; &#8221; + 93news_date);<\/p>\n<p>94 }<\/p>\n<p>95 }<\/p>\n<p>96 <\/p>\n<p>97 private void initView() {<\/p>\n<p>98 title = (TextView) findViewById(R.id.title);<\/p>\n<p>99 progressBar = (ProgressBar) findViewById(R.id.ss_htmlproges *** ar);<\/p>\n<p>100 customview_layout = (FrameLayout) 101findViewById(R.id.customview_layout);<\/p>\n<p>102 \/\/ \u5e95\u90e8\u680f\u76ee<\/p>\n<p>103 action_comment_count = (TextView) 104findViewById(R.id.action_comment_count);<\/p>\n<p>105 <\/p>\n<p>106 progressBar.setVisibility(View.VISIBLE);<\/p>\n<p>107 title.setTextSize(13);<\/p>\n<p>108 title.setVisibility(View.VISIBLE);<\/p>\n<p>109 title.setText(news_url);<\/p>\n<p>110 action_comment_count.setText(String.valueOf(news.getCommentNum()));<\/p>\n<p>111 }<\/p>\n<p>112 <\/p>\n<p>113 @Override<\/p>\n<p>114 public void onBackPressed() {<\/p>\n<p>115 super.onBackPressed();<\/p>\n<p>116 overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);<\/p>\n<p>117 }<\/p>\n<p>118 <\/p>\n<p>119 private class MyAsnycTask extends AsyncTask&lt;string, string,=&#8221;&#8221; string=&#8221;&#8221;&gt; {<\/p>\n<p>120 <\/p>\n<p>121 @Override<\/p>\n<p>122 protected String doInBackground(String&#8230; urls) {<\/p>\n<p>123 String data = NewsDetailsService.getNewsDetails(urls[0], urls[1], urls[2]);<\/p>\n<p>124 Log.i(&#8220;info&#8221;, &#8220;MyAsnycTask.data:&#8221; + data);<\/p>\n<p>125 return data;<\/p>\n<p>126 }<\/p>\n<p>127 <\/p>\n<p>128 @Override<\/p>\n<p>129 protected void onPostExecute(String data) {<\/p>\n<p>130 webView.loadDataWithBaseURL(null, data, &#8220;text\/html&#8221;, &#8220;utf-8&#8221;, null);<\/p>\n<p>131 }<\/p>\n<p>132 }<\/p>\n<p>133 <\/p>\n<p>134 \/\/ \u6ce8\u5165js\u51fd\u6570\u76d1\u542c<\/p>\n<p>135 private void addImageClickListner() {<\/p>\n<p>136 \/\/ \u8fd9\u6bb5js\u51fd\u6570\u7684\u529f\u80fd\u5c31\u662f\uff0c\u904d\u5386\u6240\u6709\u7684img\u51e0\u70b9\uff0c\u5e76\u6dfb\u52a0onclick\u51fd\u6570\uff0c\u5728\u8fd8\u662f\u6267137 \u884c\u7684\u65f6\u5019\u8c03\u7528\u672c\u5730\u63a5\u53e3\u4f20\u9012url\u8fc7\u53bb<\/p>\n<p>138 webView.loadUrl(&#8220;javascript:(function(){&#8221; + &#8220;var objs = 139document.getElementsByTagName(\\&#8221;img\\&#8221;);&#8221; + &#8220;var imgurl=&#8221;; &#8220;<\/p>\n<p>140 + &#8220;for(var i=0;i&lt;objs.length;i++) &#8220;=&#8221;&#8221; +=&#8221;&#8221; &#8220;{&#8220;=&#8221;&#8221; 141&#8243;imgurl+=&#8221;objs[i].src+&#8217;,&#8217;;&#8221;&#8221; objs[i].onclick=&#8221;function()&#8221; {=&#8221;&#8221; 142window.imagelistner.openimage(imgurl);=&#8221;&#8221; }=&#8221;&#8221; &#8220;}&#8221;=&#8221;&#8221; &#8220;})()&#8221;);=&#8221;&#8221; js\u901a\u4fe1\u63a5\u53e3=&#8221;&#8221; 143public=&#8221;&#8221; class=&#8221;&#8221; javascriptinterface=&#8221;&#8221; private=&#8221;&#8221; context=&#8221;&#8221; context;=&#8221;&#8221; 144javascriptinterface(context=&#8221;&#8221; context)=&#8221;&#8221; this.context=&#8221;context;&#8221; void=&#8221;&#8221; 145openimage(string=&#8221;&#8221; img)=&#8221;&#8221; string[]=&#8221;&#8221; imgs=&#8221;img.split(&#8220;,&#8221;);&#8221; 146arraylist&lt;string=&#8221;&#8221;&gt; imgsUrl = new ArrayList&lt;string&gt;();<\/p>\n<p>147 for (String s : imgs) {<\/p>\n<p>148 imgsUrl.add(s);<\/p>\n<p>149 Log.i(&#8220;\u56fe\u7247\u7684URL&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&#8221;, s);<\/p>\n<p>150 }<\/p>\n<p>151 Intent intent = new Intent();<\/p>\n<p>152 intent.putStringArrayListExtra(&#8220;infos&#8221;, imgsUrl);<\/p>\n<p>153 intent.setClass(context, ImageShowActivity.class);<\/p>\n<p>154 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);<\/p>\n<p>155 context.startActivity(intent);<\/p>\n<p>156 }<\/p>\n<p>157 }<\/p>\n<p>158 <\/p>\n<p>159 \/\/ \u76d1\u542c<\/p>\n<p>160 private class MyWebViewClient extends WebViewClient {<\/p>\n<p>161 @Override<\/p>\n<p>162 public boolean shouldOverrideUrlLoading(WebView view, String url) {<\/p>\n<p>163 return super.shouldOverrideUrlLoading(view, url);<\/p>\n<p>164 }<\/p>\n<p>165 <\/p>\n<p>166 @Override<\/p>\n<p>167 public void onPageFinished(WebView view, String url) {<\/p>\n<p>168 view.getSettings().setJavaScriptEnabled(true);<\/p>\n<p>169 super.onPageFinished(view, url);<\/p>\n<p>170 \/\/ html\u52a0\u8f7d\u5b8c\u6210\u4e4b\u540e\uff0c\u6dfb\u52a0\u76d1\u542c\u56fe\u7247\u7684\u70b9\u51fbjs\u51fd\u6570<\/p>\n<p>171 addImageClickListner();<\/p>\n<p>172 progressBar.setVisibility(View.GONE);<\/p>\n<p>173 webView.setVisibility(View.VISIBLE);<\/p>\n<p>174 }<\/p>\n<p>175 <\/p>\n<p>176 @Override<\/p>\n<p>177 public void onPageStarted(WebView view, String url, Bitmap favicon) {<\/p>\n<p>178 view.getSettings().setJavaScriptEnabled(true);<\/p>\n<p>179 super.onPageStarted(view, url, favicon);<\/p>\n<p>180 }<\/p>\n<p>181 <\/p>\n<p>182 @Override<\/p>\n<p>183 public void onReceivedError(WebView view, int errorCode, String description, 184String failingUrl) <\/p>\n<p>185 {<\/p>\n<p> progressBar.setVisibility(View.GONE);<\/p>\n<p> super.onReceivedError(view, errorCode, description, failingUrl);<\/p>\n<p> }<\/p>\n<p> }<\/p>\n<\/p>\n<p> private class MyWebChromeClient extends WebChromeClient {<\/p>\n<p> @Override<\/p>\n<p> public void onProgressChanged(WebView view, int newProgress) {<\/p>\n<p> \/\/ TODO Auto-generated method stub<\/p>\n<p> if (newProgress != 100) {<\/p>\n<p> progressBar.setProgress(newProgress);<\/p>\n<p> }<\/p>\n<p> super.onProgressChanged(view, newProgress);<\/p>\n<p> }<\/p>\n<p> }<\/p>\n<p>}&lt;\/string&gt;&lt;\/objs.length;i++)&gt;&lt;\/string,&gt;<\/p>\n<p>\/\/ NewsDetailsService.java<\/p>\n<p>1 package com.topnews.service;<\/p>\n<p>2 <\/p>\n<p>3 import java.io.IOException;<\/p>\n<p>4 import org.jsoup.Jsoup;<\/p>\n<p>5 import org.jsoup.nodes.Document;<\/p>\n<p>6 import org.jsoup.nodes.Element;<\/p>\n<p>7 <\/p>\n<p>8 import android.text.TextUtils;<\/p>\n<p>9 <\/p>\n<p>10 public class NewsDetailsService {<\/p>\n<p>11 public static String getNewsDetails(String url, String news_title,<\/p>\n<p>12 String news_date) {<\/p>\n<p>13 Document document = null;<\/p>\n<p>14 String data = &#8220;&#8221; +<\/p>\n<p>15 &#8220;&lt;center&gt;&lt;h2 style=&#8221;&#8216;font-size:16px;'&#8221;&gt;&#8221; + news_title + &#8220;&lt;\/h2&gt;&lt;\/center&gt;&#8221;;<\/p>\n<p>16 data = data + &#8220;&lt;p align=&#8221;&#8216;left'&#8221; style=&#8221;&#8216;margin-left:10px'&#8221;&gt;&#8221;<\/p>\n<p>17 + &#8220;&lt;span style=&#8221;&#8216;font-size:10px;'&#8221;&gt;&#8221;<\/p>\n<p>18 + news_date<\/p>\n<p>19 + &#8220;&lt;\/span&gt;&#8221;<\/p>\n<p>20 + &#8220;&lt;\/p&gt;&#8221;;<\/p>\n<p>21 data = data + &#8220;&lt;hr size=&#8221;&#8216;1&#8242;&#8221;&gt;&#8221;;<\/p>\n<p>22 try {<\/p>\n<p>23 document = Jsoup.connect(url).timeout(9000).get();<\/p>\n<p>24 Element element = null;<\/p>\n<p>25 if (TextUtils.isEmpty(url)) {<\/p>\n<p>26 data = &#8220;&#8221;;<\/p>\n<p>27 element = document.getElementById(&#8220;memberArea&#8221;);<\/p>\n<p>28 } else {<\/p>\n<p>29 element = document.getElementById(&#8220;artibody&#8221;);<\/p>\n<p>30 }<\/p>\n<p>31 if (element != null) {<\/p>\n<p>32 data = data + element.toString();<\/p>\n<p>33 }<\/p>\n<p>34 data = data + &#8220;&#8221;;<\/p>\n<p>35 } catch (IOException e) {<\/p>\n<p>36 e.printStackTrace();<\/p>\n<p>37 }<\/p>\n<p>38 return data;<\/p>\n<p>39 }<\/p>\n<p>40 }<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fhtml\u4e2d\u5982\u4f55\u7ed9\u56fe\u7247\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6\u7684\u8be6\u89e3\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c<\/p>\n<p><\/p>\n<h3>\u4e8c\uff1aunity button \u7ed1\u5b9a\u4e8b\u4ef6<\/h3>\n<p>if(GUI.Button(newRect(310,10,80,30),&#8221;\u6682\u505c&#8221;))<br \/>\u8fd9\u4e2a\u662f\u70b9\u51fbbutton\u624d\u4ea7\u751f\u7684\u4e8b\u4ef6\uff0c\u4e5f\u5c31\u662f\u4e0b\u9762\u90a3\u4e2a\u7a97\u53e3\u53ea\u663e\u793a\u4e86\u4e00\u77ac\u95f4\uff0c\u6240\u4ee5\u6ca1\u770b\u5230\u3002<br \/>\u5982\u679c\u4f60\u60f3\u5b9e\u73b0\u70b9\u51fb\u4e00\u4e0b\u7a97\u53e3\u51fa\u6765\uff0c\u518d\u70b9\u51fb\u4e00\u4e0b\u7a97\u53e3\u6d88\u5931\uff0c\u5c31\u9700\u8981\u6dfb\u52a0\u4e00\u4e2abool\u503c\u3002<br \/>publicboolWindowShow=false;<br \/>if(GUI.Button(newRect(310,10,80,30),&#8221;\u6682\u505c&#8221;))<br \/>if(WindowShow)<br \/>WindowShow=false;<br \/>WindowShow=true;<br \/>if(WindowShow)<br \/>GUI.Window(0,windowPos,mywindow,&#8221;\u6682\u505c\u7a97\u53e3&#8221;);<\/p>\n<h3>\u4e09\uff1a\u7ed9button\u7ed1\u5b9a\u70b9\u51fb\u4e8b\u4ef6<\/h3>\n<p>attr *** \u662f\u53d6\u5f97\u5c5e\u6027\u6216\u8005\u7ed9\u5c5e\u6027\u8d4b\u503c\u7528\u7684\uff0c\u7ed1\u5b9a\u4e8b\u4ef6\u7684\u8bdd\u5e94\u8be5\u7528bind *** \u3002\u3002<br \/>$(function\u00a0()\u00a0{\u00a0$(&quot;input[type=button][name=&#8217;dd&#8217;]&quot;).bind(&quot;click&quot;,\u00a0function\u00a0()\u00a0{\u00a0alert(&quot;ddd&quot;);\u00a0});\u00a0})<br \/>\u6216\u8005<br \/>$(function\u00a0()\u00a0{\u00a0$(&quot;input[type=button][name=&#8217;dd&#8217;]&quot;).click(function\u00a0()\u00a0{\u00a0alert(&quot;ddd&quot;);\u00a0});\u00a0})<\/p>\n<h3>\u56db\uff1abutton\u7ed1\u5b9a\u56de\u8f66\u4e8b\u4ef6<\/h3>\n<p>Java Swing\u672c\u8eab\u63d0\u4f9b\u4e86\u73b0\u6210\u7684\u6309\u94ae\u63a7\u4ef6JButton<br \/>\n\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6309\u94ae:JButton about = new JButton\uff1b<br \/>\n\u8fd9\u4e2a\u6309\u94ae\u8be5\u653e\u5230\u83dc\u5355\u533a\uff1atoolBar.add(about);<br \/>\n\u8981\u4e3a\u6309\u94ae\u6dfb\u52a0\u4e8b\u4ef6\u54cd\u5e94\uff0c\u9700\u8981\u4f7f\u7528about.addActionListener(this)\u6765\u544a\u8bc9\u7a0b\u5e8f\u76d1\u542c\u6309\u94ae\u6309\u4e0b\u65f6\u7684\u4e8b\u4ef6\uff0cActionListener\u662f\u4e00\u4e2a\u7a0b\u5e8f\u63a5\u53e3\u3002<br \/>\npublic class KyodaiUI extends JFrame implements ActionListener {&#8230;}\u5b9e\u73b0ActionListener\u63a5\u53e3\u662f\u4e3a\u4e86\u544a\u8bc9\u7a0b\u5e8f\u6211\u8981\u8fdb\u884c\u4e8b\u4ef6\u5904\u7406\u4e86\u3002<br \/>\n\u6700\u540e\u6211\u4eec\u5f97\u6dfb\u52a0\u54cd\u5e94\u4e8b\u4ef6\u7684\u4ee3\u7801:<br \/>\npublic void actionPerformed(ActionEvent e) {<br \/>\nif (e.getSource() == about) {<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>button\u4e8b\u4ef6\u7ed1\u5b9a\u5728\u4e00\u8d77\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u4f7f\u7528\u5b83\u4eec\u6765\u6267\u884c\u4efb\u52a1\u3002\u5982\u679c\u4f60\u4e0d\u77e5\u9053\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u51fd\u6570\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u793a\u4f8b\u6765\u5b66\u4e60\u3002\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u7c7b\uff0c\u8be5\u7c7b\u5305\u542b\u4e24\u4e2a *** \uff0c\u5206\u522b\u7528\u4e8e\u521b\u5efa\u548c \u4e00\uff1ajquery\u7ed9button\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6 \u9996\u5148\u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[99072],"tags":[],"class_list":["post-217856","post","type-post","status-publish","format-standard","hentry","category-wd"],"_links":{"self":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/posts\/217856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/comments?post=217856"}],"version-history":[{"count":0,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/posts\/217856\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/media?parent=217856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/categories?post=217856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dongwubaike.cn\/fanhao\/wp-json\/wp\/v2\/tags?post=217856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}