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

  • SEARCH
  • Home
  • 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 7687035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:36:43+00:00 2026-05-31T19:36:43+00:00

I’m working with Jquery in Drupal. I have sets of four blocks that all

  • 0

I’m working with Jquery in Drupal.
I have sets of four blocks that all share a common title, Trying to set Jquery to hide the second, third, fourth blocks when the first is clicked.

Here’s the code:

javaScript:

(function($){
  $('.view-display-id-block_1').delegate('a','hover',function(){
    var linkText = $(this).text();
    var viewSelectString= '.views-field-title:contains('+linkText+')';
    var textSelect = $('p,li,a,span',$(viewSelectString));
    var recordString = 'div.views-field-title:contains('+linkText+')';
    var recordStringRefine = 'li .views-row:has('+recordString+')';
    var recordStringSelect = $(recordStringRefine);
    $recordStringSelect.hide();
  });
})(jQuery);

HTML:

<li><p class='views-field-title'>contains linkText</p><p></p><p></p></li>
<li><p class='views-field-title'>contains linkText</p><p></p><p></p></li>
<li><p class='views-field-title'>contains linkText</p><p></p><p></p></li>
<li><p class='views-field-title'>contains linkText</p><p></p><p></p></li>

Using delegate() because the jQuery version is too old to support on()

So the first half of the query works fine, I can select any element within the four blocks.
Each block has a number of elements, I want to go up a level, find the parent <li> that contains each block, and hide that.

When I add the recordString stuff, my query stops working. All the has() examples I can find only select by element.

In-context there’s a lot of other classes and elements floating around, but basically I need to select elements based on whether they include ‘linkText’, then somehow travel up the tree to the wrapper li and hide that (and hopefully everything that it contains).

Can’t find much info on whether has() supports pseudo-selectors and all that, in any case it seems like its starting to get kind of complicated and confusing. Definitely can’t make the code run. Is this just the wrong way to get this done?

Thanks, I appreciate the help

  • 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-05-31T19:36:44+00:00Added an answer on May 31, 2026 at 7:36 pm

    The solution may be as simple as this:

    $(function(){
        $('.view-display-id-block_1').delegate('a', 'hover', function(){
            $(".views-field-title:contains(" + $(this).text() + ")").closest('li').hide();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.