Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7772967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:00:23+00:00 2026-06-01T17:00:23+00:00

When I click a node in a drupal view it toggles the body for

  • 0

When I click a node in a drupal view it toggles the body for every node in my view instead of just the node I am clicking. How can I get jquery to toggle just the node I am clicking? Here is my code in the head of my node template (node-type.tpl.php)

 <script>
 $("button").click(function () {
 $(".more").toggle();
 });
 </script>

And the code for the body to be toggled.

 <div class="more"><?php print $node->content['body']['#value']; ?></div>

Currently it toggles every div with the class “more” in my entire view instead of just in the node which I am clicking. How do I restrict it to just the clicked node?

I would also like it if only body were open at a time. ie; when a different node is clicked, the previous node’s body toggles closed.

I’m sure it’s probably easy but I just can’t seem to figure it out…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:00:24+00:00Added an answer on June 1, 2026 at 5:00 pm

    Where is the button relative to .more?

    If the button is in the .more element, you want to do something like this:

    $("button").click(function () {
        $('.more').hide();
        $(this).closest(".more").show();
    });
    

    If the button is not a parent or ancestor of .more, you will need to do a little more. If the buttons are in the same order as the .more elements (and there aren’t any unrelated buttons), you can do this:

    $("button").click(function () {
        $('.more').hide();
        $('.more').eq( $('button').index( $(this) ) ).show();
    });
    

    However, you are better off linking the button to the .more content with an id and a href, or some jQuery data:

    <button class='morebutton' data-more="#more1">Button 1</button>
    <button class='morebutton' data-more="#more2">Button 2</button>
    <div class='more' id="more1">More Number 1</div>
    <div class='more' id="more2">More Number 2</div>
    

    Script:

    $(".morebutton").click(function () {
        $('.more').hide();
        $( $(this).data('more') ).show();
    });
    

    Demo: http://jsfiddle.net/jtbowden/EfUxt/

    There are libraries that help with these kinds of situations, such as jQuery UI Tabs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Drupal 6. I have created a node type which consists of just a body
On Drupal 6 I am attaching a file to a node. This can be
i use jquery treeview http://docs.jquery.com/Plugins/Treeview/treeview i want to catch click on text node and
I have a view of nodes in drupal. Each node has button which (is
I'm trying to add in a double click on a node in the force
I want to show popup box on a right-click at JTree node only, not
Click here to see what I mean.. What could prevent these two from sitting
On click a image how can another page be previewed in the same page
When click a button,I want to popup a view form bottom,like this! Any help
I'm using Views in Drupal to show node teasers. I would like now to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.