全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1786|回复: 15
打印 上一主题 下一主题

求大神帮忙写下js

[复制链接]
跳转到指定楼层
1#
发表于 2015-12-16 19:58:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 村长 于 2015-12-16 20:00 编辑
  1. <div class="Mbox-btn">
  2. <a href="javascript:{};" class="Mbox-tezt down">下载全部</a>
  3. </div>
  4. </div>
  5. <div class="Mbox-bd clearfix">
  6. <div class="clickTab-bd">
  7. <div class="newBoxItem" style="display: block;" id="f1">
  8. <ul class="musicList music2_L">
  9. <li class="top3"><input style="display: none;" type="checkbox" name="Url" did="12"><span class="num">1</span><span class="singerNameWrap"><a href="/" class="songName" target="_1" >1</a></span><span class="itemCao"></li>
  10. <li class="top3"><input style="display: none;" type="checkbox" name="Url" did="18"><span class="num">2</span><span class="singerNameWrap"><a href="/" class="songName" target="_1" >2</a></span></li>
  11. <li><input style="display: none;" type="checkbox" name="Url" did="19"><span class="num">3</span><span class="singerNameWrap"><a href="/" class="songName" target="_1" >3</a></span></li>
复制代码



<a href="javascript:{};  这个按钮=打开..com?id=12,18,19 (12 18 19是did的值)
2#
发表于 2015-12-17 00:05:25 | 只看该作者
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6. </head>
  7. <body>
  8. <div class="Mbox-btn"><a  class="Mbox-tezt down" id="open">下载全部</a></div>
  9. <input style="display: none;" type="checkbox" name="Url" did="12">
  10. <input style="display: none;" type="checkbox" name="Url" did="18">
  11. <input style="display: none;" type="checkbox" name="Url" did="19">
  12. </body>
  13. <script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
  14. <script>
  15. $(document).ready(function(){
  16.     $('#open').click(function(){
  17.         $('#open').attr('href','http://www.lovekk.org/?id='+$('input[name=Url]:eq(0)').attr('did')+','+$('input[name=Url]:eq(1)').attr('did')+','+$('input[name=Url]:eq(2)').attr('did'));
  18.     });
  19. });
  20. </script>
  21. </html>
复制代码
4#
 楼主| 发表于 2015-12-17 15:19:33 | 只看该作者
5#
 楼主| 发表于 2015-12-17 15:41:44 | 只看该作者

在问下 在新窗口打开怎么修改,

  1. .attr('did')+','+$('input[name=Url]:eq(1)')
  2. [code].attr('did')+','+$('input[name=Url]:eq(2)')
  3. *
  4. *
  5. .attr('did')+','+$('input[name=Url]:eq(15)')
  6. .attr('did')+','+$('input[name=Url]:eq(16)')

  7. 能简写吗
复制代码
6#
发表于 2015-12-17 19:59:10 | 只看该作者
村长 发表于 2015-12-17 15:41
在问下 在新窗口打开怎么修改,

好像不能简写,至于新窗口打开,这是最基本的HTML啊。。。。

  1. <a  target="_blank">新窗口打开</a>
复制代码
7#
发表于 2015-12-17 20:23:27 | 只看该作者
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8">
  5.   <title>demo</title>
  6. </head>
  7. <body>
  8.   <div class="Mbox-btn">
  9. <a href="javascript:{};" class="Mbox-tezt down">下载全部</a>
  10. </div>
  11. </div>
  12. <div class="Mbox-bd clearfix">
  13. <div class="clickTab-bd">
  14. <div class="newBoxItem" style="display: block;" id="f1">
  15. <ul class="musicList music2_L">
  16. <li class="top3"><input style="display: none;" type="checkbox" name="Url" did="12"><span class="num">1</span><span class="singerNameWrap"><a href="/" class="songName" target="_1" >1</a></span><span class="itemCao"></li>
  17. <li class="top3"><input style="display: none;" type="checkbox" name="Url" did="18"><span class="num">2</span><span class="singerNameWrap"><a href="/" class="songName" target="_1" >2</a></span></li>
  18. <li><input style="display: none;" type="checkbox" name="Url" did="19"><span class="num">3</span><span class="singerNameWrap"><a href="/" class="songName" target="_1" >3</a></span></li>
  19. <script src="http://cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
  20. <script>
  21. $(document).ready(function(){
  22.     $('.down').click(function(){
  23.                 var did = [];
  24.                 $('input[name=Url]').each(function(){
  25.                         var has_did = $(this).attr('did');
  26.                         if(typeof has_did !== 'undefined' && has_did !== false){
  27.                                 did.push($(this).attr('did'));
  28.                         }                       
  29.                 });               
  30.                 if(did.length == 0){
  31.                         return;
  32.                 }
  33.                 var did_string = did.join(',');
  34.                 window.open('http://www.xxx.com/?id='+did_string);
  35.     });
  36. });
  37. </script>
  38. </body>
  39. </html>
复制代码
8#
 楼主| 发表于 2015-12-17 23:04:55 | 只看该作者

感谢,完美实现了。

  1. $(document).ready(function(){
  2.     $('.down').click(function(){
  3.                 var did = [];
  4.                 $('input[name=Url]').each(function(){
  5.                         var has_did = $(this).attr('did');
  6.                         if(typeof has_did !== 'undefined' && has_did !== false){
  7.                                 did.push($(this).attr('did'));
  8.                         }                        
  9.                 });               
  10.                 if(did.length == 0){
  11.                         return;
  12.                 }
  13.                 var did_string = did.join(',');
  14.                 window.open('http://www.xxx.com/?id='+did_string);
  15.     });
  16. });
复制代码


还有一个问题,实际页面是选项卡形式的 也就是有f1 和 f2
<div class="newBoxItem" style="display: block;" id="f1">
<div class="newBoxItem" style="display: block;" id="f2">

<a href="javascript:{};" class="Mbox-tezt down">下载全部</a>按钮是公用的

id="f1">和 id="f2">下面的 did是不一样的  这个怎么实现
9#
发表于 2015-12-17 23:37:03 | 只看该作者
本帖最后由 psdshow 于 2015-12-17 23:39 编辑
  1. $(document).ready(function(){
  2.     $('.down').click(function(){
  3.                 //获得当前action的tab
  4.                 var active_tab = 'f1';
  5.                 $('.newBoxItem').each(function(){
  6.                         if($(this).attr('display') === 'block'){
  7.                                 active_tab = $(this).attr('id');
  8.                         }
  9.                 });
  10.                                
  11.                 var did = [];
  12.                 $('#'+active_tab+' input[name=Url]').each(function(){
  13.                         var has_did = $(this).attr('did');
  14.                         if(typeof has_did !== 'undefined' && has_did !== false){
  15.                                 did.push($(this).attr('did'));
  16.                         }                        
  17.                 });               
  18.                 if(did.length == 0){
  19.                         return;
  20.                 }
  21.                 var did_string = did.join(',');
  22.                 window.open('http://www.xxx.com/?id='+did_string);
  23.     });
  24. });
复制代码
10#
发表于 2015-12-18 00:32:53 | 只看该作者
LOC大神真多~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-12-5 19:13 , Processed in 0.090388 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表