全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1787|回复: 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的值)
16#
 楼主| 发表于 2015-12-18 12:26:06 | 只看该作者
感谢psdshow,感谢october,感谢loc mjj 完美解决了。

敬礼
15#
发表于 2015-12-18 12:14:38 | 只看该作者
借用october的方法改了一下

  1. $(document).ready(function(){
  2.     $('.newBoxPlay1').unbind().click(function(){
  3.                 //获得当前action的tab
  4.                 var active_tab = 'f1';
  5.                 $('.newBoxItem').each(function(){
  6.                         if($(this).is(':visible')){
  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. });
复制代码
14#
 楼主| 发表于 2015-12-18 10:42:32 | 只看该作者
13#
发表于 2015-12-18 10:33:21 | 只看该作者
  1. $(document).ready(function(){
  2.     $('.newBoxPlay1').click(function(){
  3.                 //获得当前action的tab
  4.                 var active_tab = 'f1';
  5.                 if( $('#f2').is(':visible') ){
  6.                     active_tab = 'f2';
  7.                 }
  8.                                  
  9.                 var did = [];
  10.                 $('#'+active_tab+' input[name=Url]').each(function(){
  11.                         var has_did = $(this).attr('did');
  12.                         if(typeof has_did !== 'undefined' && has_did !== false){
  13.                                 did.push($(this).attr('did'));
  14.                         }                        
  15.                 });               
  16.                 if(did.length == 0){
  17.                         return;
  18.                 }
  19.                 var did_string = did.join(',');
  20.                 window.open('http://www.xxx.com/?id='+did_string);
  21.                 }
  22.     });
  23. });
复制代码
12#
发表于 2015-12-18 09:41:26 | 只看该作者
各位大神真热心,给个赞
11#
 楼主| 发表于 2015-12-18 09:01:14 | 只看该作者

大波妹起来尿尿了。。

f2的怎么添加是这样吗
  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.                 var active_tab = 'f2';
  11.                 $('.newBoxItem').each(function(){
  12.                         if($(this).attr('display') === 'block'){
  13.                                 active_tab = $(this).attr('id');
  14.                         }
  15.                 });
  16.                                 
  17.                 var did = [];
  18.                 $('#'+active_tab+' input[name=Url]').each(function(){
  19.                         var has_did = $(this).attr('did');
  20.                         if(typeof has_did !== 'undefined' && has_did !== false){
  21.                                 did.push($(this).attr('did'));
  22.                         }                        
  23.                 });               
  24.                 if(did.length == 0){
  25.                         return;
  26.                 }
  27.                 var did_string = did.join(',');
  28.                 window.open('http://www.xxx.com/?id='+did_string);
  29.     });
  30. });
复制代码

  1. http://61.160.196.94/
复制代码
这个是测试网址 还是只要f1有效
10#
发表于 2015-12-18 00:32:53 | 只看该作者
LOC大神真多~
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. });
复制代码
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是不一样的  这个怎么实现
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-12-5 22:06 , Processed in 0.088587 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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