通过名称查找变量后设置var值

时间:2016-02-02 11:04:44

标签: javascript jquery

我开始构建一个脚本,到目前为止它有3个属性。 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FEBF48" /> </shape>

我想循环浏览用户输入的属性,并使用正确的public class MainActivity extends ActionBarActivity { Button login_button; Button signup_button; private static final String CONSOLETAG = "consoleDebug : "; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Click on signup button signup_button = (Button) findViewById(R.id.signupButton); signup_button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Nothin } }); // Click on login button login_button = (Button) findViewById(R.id.loginButton); login_button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Nothin } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); return super.onOptionsItemSelected(item); } public void goToSignup(View view) { Intent intent = new Intent(this, SignupActivity.class); startActivity(intent); } } 设置值。

var url, top, left;

这在某种程度上是可行的,还是有一种更简单的方法。?

1 个答案:

答案 0 :(得分:0)

你可以这样做:

$(document).ready(function () {
    $.fn.initEmail({
        url: "localhost:54623",
        left: "10",
        top: "15"
    });
});



$.fn.initEmail = function (options) {
    var url = options.url, top = options.top, left = options.left;
    var opts = $.extend({}, $.fn.initEmail.Options, options);

}