Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

How to apply border on input?

I'm amazed this works: demo

<span>
<input type="checkbox" />
</span>

span{
    border: 1px solid red;
}

But this doesn't work: demo

<input type="checkbox" />

$('input').wrap('<span />').css('border','1px solid red');

Upvotes: 2

Views: 48

Answers (1)

Felix
Felix

Reputation: 38102

You need to apply the border on <span> element, not <input> so you can traverse up one level using .parent():

$('input').wrap('<span />').parent().css('border','1px solid red');

Updated Fiddle

Upvotes: 6

Related Questions