【问题标题】:jquery selector rel=re attributejquery 选择器 rel=re 属性
【发布时间】:2015-10-02 13:04:44
【问题描述】:

我从一家处理分数表的公司那里得到了一个脚本。

我只想显示第二个标签“Uitslagen”rel="re",但它的标准在第一个标签上打开。 我想我应该可以用 JQuery 伪造点击。

您可以在以下位置查看脚本:http://hvdws.nl/Uitslagen/clubplugin.html

<body>
		<div id="club-plugin"></div>

		<script     src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">  </script>
		<script src="http://www.handbal.nl/kcp/e78a2135307b088e8a/"></script>
		<link type="text/css" href="clubplugin2-style.css" rel="stylesheet" />
		<link type="text/css" href="clubplugin2-grey.css" rel="stylesheet" />
		<script>
			jQuery(document).ready(function($){
				clubplugin.load('#club-plugin'); 
			});

		</script>
	</body>

这是类:

<div class="o-kcp-tabs">
  <div class="o-kcp-tab-item first active" rel="pr" style="width:25%;">Programma</div>
  <div class="o-kcp-tab-item" rel="re" style="width: 25%;">Uitslagen</div>
  <div class="o-kcp-tab-item" rel="st" style="width: 25%;">Standen</div>
  <div class="o-kcp-tab-item last" rel="te" style="width: 25%;">Teams</div>
</div>

我在 Stackoverflow 上找到了这个链接: selector in jquery - get rel attribute

但无法真正弄清楚如何编写脚本。

有没有人可以帮助我,我觉得这是一个非常简单的问题,我只是在 Jquery 中不够熟练,无法弄清楚。

这就是我现在拥有的:

$('#club-plugin').click(function(){
  var rel = $('.o-kcp-tabs').attr('rel', "re");	

【问题讨论】:

    标签: jquery attributes rel


    【解决方案1】:

    这会删除所有具有rel="re"并且是.o-kcp-tabs的直接子代的.o-kcp-tab-item元素:

    jQuery(document).ready(function($){
        $('.o-kcp-tabs>.o-kcp-tab-item:not([rel~="re"])').remove();
        clubplugin.load('.o-kcp-tabs'); 
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-08
      • 1970-01-01
      • 2010-10-19
      相关资源
      最近更新 更多