Skip to content

Instantly share code, notes, and snippets.

@amuhororo
Last active March 28, 2016 14:21
Show Gist options
  • Save amuhororo/11e02a29c3d067b34265 to your computer and use it in GitHub Desktop.
Save amuhororo/11e02a29c3d067b34265 to your computer and use it in GitHub Desktop.
[button]にもテキスト表示できるようにする。
if(pm.text!=""){ //テキスト指定があったらdivにする
 var j_button=$("<div></div>");
 j_button.text(pm.text);
  //↓面倒くさいので纏めちゃったけど、ifで指定がある時だけ追加とかにした方がスッキリするかもしれない。
 j_button.css({"color":pm.color,"font-size":pm.size+"px","text-align":"center"});
 if(pm.graphic!="")j_button.css("background-image","url('"+storage_url+"')");
}
else { //テキスト指定が無かったらimg
  //↓同じ記述は削除。この3行以外はそのままでOK
 var j_button=$("<img alt="" />");
 j_button.attr("src",storage_url);
 if(pm.hint!="")j_button.attr({"title":pm.hint,"alt":pm.hint});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment