Solved

CSS Selector problem

Posted on 2014-03-27
2
221 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
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 43

Accepted Solution

by:
Chris Stanyon earned 500 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

806 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