English 中文(简体)
页: 1 表演/表演
原标题:jQuery show/hide rule
  • 时间:2011-01-07 15:49:47
  •  标签:
  • jquery

基本上,我正试图展示隐藏的干.和联系,但有一些麻烦。 所需功能如下:

  • On page load, DIV ID additional-languages is hidden
  • User can click the Selected Additional Languages link which will show the additional-languages DIV
  • At the point of clicking this link, the link will get hidden
  • User can then choose to hide the additional-languages DIV by clicking on the hide link
  • At the point of clicking this link, the Selected Additional Languages link will re-appear

在这方面,我迄今为止已经做了以下工作:

标记:

<div class="row">
    <label for="native_language">Select</label>
    <select name="native_language" id="native_language">
      <option value="">Any</option>
      <option value="1">English</option>
    </select>

    <a class="show-additional-link" href="#">Select Additional Languages</a>
</div>

<div id="additional-languages" style="display: none;">
    <a class="hide-additional-link" href="#">[hide]</a>

    <div class="row">
        <!-- additional language checkboxes -->
    </div>
</div>

JS:

$( .show-additional-link ).click(function(){
    $(this).parent().next().slideDown();
    $(this).hide();
    return false;
});

The first part is working for me, but I m struggling on getting the second part to work, i.e. the functionality for the hide-additional-link . I have tried this:

$( .hide-additional-link ).click(function(){
    $(this).parent().slideUp();
    $(this).parent().prev( .show-additional-link ).show();
    return false;
});

DIV是隐蔽的,但显示-附加联系没有显示。

最佳回答

修改:

$(this).prev( .show-additional-link ).show();

为此:

$(this).parent().prev("div.row").find( .show-additional-link ).show();

<代码>.prev将严格地针对以前的兄弟姐妹。 页: 1 显示-附加联系。

问题回答

如果是我的话,我只读到$>>,以供阅读和检索。 您希望,在不必触及javascript代码的情况下,国际标准化组织设计师很容易在网页上移动超文本。

如果在网页上有多个<代码>.show-additional-link,就开始给这些代码。

你们必须使用

$(this).parent().prev().find( .show-additional-link ).show();

由于<代码>.show-additional-link,inside the prev content.

亲爱!

$( .hide-additional-link ).click(function(){
    $(this).parent().slideUp();
    $(this).parents( #additional-languages ).prev( .row ).find( .show-additional-link ).show();
    return false;
});

回答: 你的隐藏-附加联系功能正在研究以前与阶级显示-再联系的相互交织的项目的“补充语言”。 它需要研究。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签