?
Solved

CSS Selector problem

Posted on 2014-03-27
2
Medium Priority
?
237 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 43

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

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

801 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