Pawan
Pawan

Reputation: 3864

jquery insert after multiple conditions

I want to insert a span element after a input element matching the class as well as input type that is checkbox for styling the checkbox element.

I am able to achieve it for class selector only for example: the input element looks like this:

<input data-attrname="artist" class="layered_attrs" id="57" type="checkbox">

and I want to add the element after this like

<span class="checkmark"></span>

I can achieve this using:

$( "<span class='checkmark'></span>" ).insertAfter( ".layered_attrs" );

but I also want to validate type that is input id with class layered_attrs and type is checkbox

Upvotes: 1

Views: 187

Answers (1)

charlietfl
charlietfl

Reputation: 171679

Can use :checkbox selector:

$( "<span class='checkmark'></span>" ).insertAfter( ".layered_attrs:checkbox" );

Or attribute selector

$( "<span class='checkmark'></span>" ).insertAfter( ".layered_attrs[type='checkbox']" );

Upvotes: 1

Related Questions