0

How can i apply the css to multiple controls in jquery ? Controls prefix is same.

I have tried this so far but it is not working;

var id = '#myorders_ctl' + cntrlId + '_';
 $(id + 'spanUpdateOrderItem', id + 'btnMinusOrderItem', id + 'btnAddOrderItem').css({ 'display': 'none' });

1 Answer 1

2

The ids all need to be in a single selector string:

var id = '#myorders_ctl' + cntrlId + '_';
$(id + 'spanUpdateOrderItem,' + id + 'btnMinusOrderItem,' + id + 'btnAddOrderItem').hide();

I'd also suggest you research DOM traversal and common classes as incremental id attributes are an anti-pattern and lead to needlessly verbose logic, like the above.

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

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.