0

How can I target the <input> only when there is <span> after it?

<fieldset>
   <p>Normal Input</p>
   <div>
     <input name="">
     <span><i class="icon-cart"></i></span>
   </div>
</fieldset>

input + span {} would only work if the <span> was before the <input> but in this case it is after the <input> - Is there a way to target it without using JavaScript or adding classes to the parent container?

enter image description here

As you can see in the image below, I just want to change the input border-radius so it merge with the span icon us like on all the other scenarios.

BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
Leo
  • 957
  • 2
  • 13
  • 35

1 Answers1

1

If you want to add a class say, you could use JQuery like this:

$('span').prev('input').addClass('test');

Or to add a border-radius:

$('span').prev('input').css('border-radius','3px');
StudioTime
  • 20,816
  • 34
  • 110
  • 202