3

I have List of Check-boxes array and i want to get specific checkbox by specific attribute.

lets i have 20 checkedboxes in an array object. and each checkbox contains attribute tradeId

<input name="chkTrades" type="checkbox" tradeId="1">

i want to get only checkbox having tradeId=1

how to get it

2

2 Answers 2

4

You can select attributes in jquery pretty easily:

$('input[type=checkbox][tradeId=1]');

console.log($('input[type=checkbox][tradeId=1]')[0]);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input name="chkTrades" type="checkbox" tradeId="1">
<input name="chkTrades" type="checkbox" tradeId="2">
<input name="chkTrades" type="checkbox" tradeId="3">

Sign up to request clarification or add additional context in comments.

Comments

1

select check box by attribute

$('input:checkbox[tradeId=1]');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.