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
  • 700,868
  • 160
  • 1,392
  • 1,356
Leo
  • 967
  • 2
  • 14
  • 37

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
  • 22,603
  • 38
  • 120
  • 207