How to target the last child element using a specific class name in JQuery

I need to target the last child of a class called full-width in order to remove the border-bottom styling. The text is part of a loop and I want to ensure that the last child does not have the border. To make sure it works in IE8, I am using JQuery as follows:

Unfortunately, my current implementation is not working.

JQuery

$(".solutions-section .field-items .field-item div:last-child").css("border-bottom","none");

HTML

<div class="full-width info-block solutions-section">
    <div class="field field-name-field-solutions-area field-type-text-long field-label-hidden">
       <div class="field-items">
          <div class="field-item even" style="border-bottom-style: none;"><h2>A Para</h2>

              <div class="full-width solid-block">
                  <div class="alignleft onethird-width ">
                      <img border="0" src="sites/all/themes/ourbrand/images/image.png" width="120">
                  </div>
                  <div class="alignleft qtr-width small-text dark-grey">
                       Who is it for? All Text</div>
                  <div class="clear">&nbsp;</div>

              </div>

              <div class="full-width solid-block">
                  <div class="alignleft onethird-width ">
                      <img border="0" src="sites/all/themes/ourbrand/images/image.png" width="120">
                  </div>
                  <div class="alignleft qtr-width small-text dark-grey">
                       Who is it for? All Text</div>
                  <div class="clear">&nbsp;</div>

              </div>

</div></div></div></div>

Answer №1

Your current selection seems to be targeting all divs within the item-field class, not just the child div. You may want to try adding a '>' before the div to narrow down your selection.

$(".solutions-section .field-items .field-item > div:last").css("border-bottom","none")

For an example, check this http://jsfiddle.net/w6s6puLu/

Answer №2

If I understand your issue correctly, you may be able to solve it using this code snippet:

$(".solutions-section .field-items .field-item div.full-width:last-child").css("border", "2px solid green");

Check out the demo here

Give it a try and let me know if it works for you!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can images styled with CSS be captured by Selenium using find_elements_by_tag_name("img")?

Being new to web programming and Selenium, I am quite curious about something. If I were to execute the selenium command `.find_elements_by_tag_name("img")`, would it be able to capture CSS images? Can anyone shed some light on this for me? Thank you. ...

Innovative solutions for seamless transformation of HTML designs into Silverlight 3.0

One of my challenges with clients is getting them on board with web applications. However, I am eager to try something new and explore the potential of Silverlight 3.0. It would be great to see if I can transform some of these applications into fully funct ...

Three.js Ellipse Curve Rotation

Purpose My goal is to create an EllipseCurve () where a camera will move. The Approach I Took to Achieve the Goal Below is the code snippet for creating the ellipse: var curve = new THREE.EllipseCurve( 0, 0, 1, 1, 0, 2 * Math.PI, false, ...

Spacing the numbers on the D3 Y Axis by intervals of 25

Below is the D3 js code I am working with: const svg = select(svgRef.current); const { width, height } = wrapperRef.current.getBoundingClientRect(); const stackGenerator = stack().keys(keys); const layers = stackGenerator(data); const extent = [0, 100]; ...

Creating a full-width layout with CSS div

Seeking the most stylish method to create a layout similar to this using divs in IE7 and other modern browsers (Chrome, Firefox, etc). Appreciate your help! ...

Complicated scenario involving distinct identifiers and dynamically generated items

I am facing an issue with a button that, when clicked, adds a new media item to a list. The problem is that it uses unique IDs that end up getting duplicated. I am looking for a solution to add some kind of anonymous number to the ID to prevent duplication ...

Can anyone assist me with this HTML/jQuery code?

Despite my efforts, I've been unable to achieve success. The challenge I'm facing is with duplicating controls for adding images. I have a button and a div where the user can choose an image by clicking the button. The selected image appears in ...

Invoke index functions within a component

I have a widget/component written in Angular 4 within the index.html file. Before and after this angular app, there are various HTML elements due to the nature of it being an additional component for the website. The head section of the index file include ...

Navigating through undefined state while iterating through an array of objects extracted from an API in React

When the component mounts, API data is fetched and the state is initialized in the following form: sectionData: { course: null, section_id: null, semester: null, number: null, seats: null, meetings: [], open_seats: null, waitlist: null, ...

Looking to incorporate nested rules in `JSS` using `CSS`?

Can someone guide me on how to use CSS class-nesting in Material-UI or JSS in general? I have been attempting the following: card: { cardHeader:{ marginTop:"30px" } } ...

Is there a way to make Outlook show only the caption of a link instead of the entire URL?

In my PDF file, I have set up a button for sending an email. The email is a request that needs approval or denial. I want the recipient to respond with just 2 clicks: Click on either "Approve" or "Deny" (a new email will pop up) Click on "send" - and it& ...

Add the 'table' class to a WooCommerce table following an AJAX request

When it comes to WooCommerce-tables, there are predefined classes such as shop_table shop_table_responsive cart woocommerce-cart-form__contents. Surprisingly, there is no table class included, which means Bootstrap tables cannot be utilized easily. Intere ...

I am attempting to establish a connection with the Converge Pro 2 system from Clearone using NodeJS node-telnet-client, but unfortunately, my efforts to connect have been unsuccessful

My connection settings are as follows: { host: '192.168.10.28', port: 23, shellPrompt: '=>', timeout: 1500, loginPrompt: '/Username[: ]*$/i', passwordPrompt: '/Password: /i', username: 'clearone ...

Adjusting text to begin after a variable by two spaces (equivalent to 5 pixels)

When displaying the echoed text below, I noticed that "DURING" sometimes overlaps with the variable $submittor when there are not enough &nbsp;s. On the other hand, if too many &nbsp;s are added, there ends up being excessive space between $submitt ...

Transform Euler Angles into Vectors by utilizing Euler's "setFromVector3" method

Given three Euler angles x, y, z in radians, I am looking to convert them into a Vector location X, Y, Z with the center as the origin. If it is possible to utilize https://threejs.org/docs/#api/en/math/Euler.toVector3 to obtain the Vector, I would apprec ...

Submenu animation that "bursts onto the scene"

I'm facing an issue with my menu that has sub-items inside it. To achieve the animation effect I desire, I need to extract the width, height, and first-child's height of the sub-menu. While my animation is working most times, there are instances ...

Is there a labeling feature available on leaflet maps?

Does anyone have information on how to include a label next to markers on a react-leaflet map? ...

Attempting to create a multi-page slider using a combination of CSS and JavaScript

Looking for help with creating a slider effect that is triggered when navigating to page 2. Ideally, the div should expand with a width of 200% or similar. Any assistance would be greatly appreciated! http://jsfiddle.net/juxzg6fn/ <html> <head& ...

The ng-model in Angular is unable to capture the initial input value on load

I am currently using a window onload script to obtain longitude and latitude data and pass them to hidden input values. $(function() { window.onload = getLocation; var geo = navigator.geolocation; function getLocation() { if (geo) { geo ...

React state will only return a single element

I've been working on updating the state and using the updated state for rendering. After I click and make modifications (such as adding {isClicked: true} to an array), the console.log(this.state.listOfQuotes) within the onClicked function displays t ...