您好我有一个页面,其中包含<a>
个下载pdf文件的链接。现在我必须按一个按钮来下载该页面上的所有可用文件。现在如何在按钮点击的所有链接上触发点击事件?
<button class="download-all"/>
<a class="link" href="file.html"/>
<a class="link" href="file2.html"/>
现在点击按钮,点击所有带link
课程的链接。
答案 0 :(得分:0)
您的HTML不正确,请使用以下内容进行修改。
HTML,
$('button.button').on('click', function(){
$('a.link').click(); //fires click to all a with class "link"
});
//Anchor tag click Event
$('a.link').click(function(e){
e.preventDefault();
var href = $(this).attr("id");
window.location.href = href;
});
JS,
public class ParseJSON {
public static String[] position1;
public static String[] team;
public static String[] points;
public static final String JSON_ARRAY = "data";
public static final String CHILD_ARRAY = "standings";
public static final String KEY_ID = "position";
public static final String KEY_NAME = "team";
private JSONObject users = null;
private JSONArray user2=null;
private JSONObject user3=null;
private String json;
public ParseJSON(String json){
this.json = json;
}
protected void parseJSON() {
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject(json);
users = jsonObject.getJSONObject(JSON_ARRAY);
try {
user2=users.getJSONArray(CHILD_ARRAY);
position1 = new String[user2.length()];
team = new String[user2.length()];
points=new String[user2.length()];
for (int i = 0; i < user2.length(); i++) {
JSONObject jo = user2.getJSONObject(i);
try {
user3=jo.getJSONObject("overall");
points[i] = user3.getString("points");
System.out.println("Message me: "+points[i]);
}catch (Exception e)
{
e.printStackTrace();
}
position1[i] = jo.getString(KEY_ID);
team[i] = jo.getString(KEY_NAME);
System.out.println("Message me: "+position1[i]);
System.out.println("Message me: "+team[i]);
}
}catch (Exception e)
{
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
答案 1 :(得分:0)
我不确定使用标准网络技术是否可行,因为HTTP一次不支持多个文件下载。
<强>解决方案: - 强>
打开多个窗口以启动文件下载
最简单的方法是将捆绑到ZIP文件中的多个文件提供服务。所以任何人都可以下载zip文件。