[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CSS Selector problem

Posted on 2014-03-27
2
Medium Priority
?
241 Views
Last Modified: 2014-04-08
I have a problem to point out two objects having the same class.

If I use the CSS selector:

@FindBy(css = ".searchform .sprite.limitbox-trigger")

it points out both objects.

I need two different CSS selectors pointing out the objects separately.

Here is the code:

Object 1:

<input type="text" id="what" name="what" value="">
<a class="sprite limitbox-trigger  helper" href="#" data-text="Click to view extra options on how to limit your search"></a>

Object 2:

<input type="text" id="where" name="where" value="">
<a class="sprite limitbox-trigger  helper" href="#" data-text="Click to view extra options on how to limit your search"></a>


I understand I need to use the id="where" or name="where" but I don't get the combination with class to work...
0
Comment
Question by:Bear2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:soupBoy
ID: 39959042
Your id's should be unique, but if that won't work, you could always find the first one by using :first-of-type...however I don't believe that will work in IE8 (if you have to support it).

.searchform .sprite.limitbox-trigger:first-of-type

Open in new window


You mention using the input attributes...which could get ugly but might work for you
input[id="someID"] + .searchform .sprite.limitbox-trigger

Open in new window

I only used the ID as it would be unique...but you could easy 'chain' the other parts of the selector....  [id="someID"][name="someName"] etc.


Let me know if I am way off base with this...


- Chris
0
 
LVL 44

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 39959116
Just use the adjacent sibling selector (+)

#what + .sprite.limitbox-trigger
#where + .sprite.limitbox-trigger

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question