我想用上传的文件替换div的背景。 请注意,此div是我的上传按钮,其背景更改为:hover和:active。 当文件应上传到后台时,:hover和:active属性应该不起作用。
HTML
$('#calendar').fullCalendar({
eventRender: function(event, element, view){
element.click(function(){
alert('test');
})
}
});
CSS
public class BackendTest extends AndroidTestCase {
private static MyApi myApiService = null;
private Context context;
public void testAsyncJoke () throws Throwable{
// create a signal to let us know when our task is done.
final CountDownLatch signal = new CountDownLatch(1);
final AsyncTask<Pair<Context, String>, Void, String> myTask = new AsyncTask<Pair<Context, String>, Void, String>() {
@Override
protected String doInBackground(Pair<Context, String>... params) {
if(myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setRootUrl("https://androidnanodegreprojectfour.appspot.com/_ah/api/");
myApiService = builder.build();
}
context = params[0].first;
String name = params[0].second;
try {
return myApiService.sayHi(name).execute().getData();
} catch (IOException e) {
return e.getMessage();
}
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
signal.countDown();
}
};
// Execute the async task on the UI thread! THIS IS KEY!
runTestOnUiThread(new Runnable() {
@Override
public void run() {
myTask.execute("Do something");
}
});
signal.await(30, TimeUnit.SECONDS);
// The task is done, and now you can assert some things!
assertTrue("Happiness", true);
}
}
答案 0 :(得分:1)
我想我得到了你。
我这样做了:
$("#uploader1").change(function(){
$("#myImg1").css("background-image", "url("+URL.createObjectURL($(this)[0].files[0])+")");
});