0

i've selected the following Ids in angularjs and i want to set the css to diplay none. the following code works well

angular.element(document.getElementById('cont_' + i)).css({display: 'none' })
angular.element(document.getElementById('resize_' + i)).css({ display: 'none' })

is there a way to chain both selectors to i don't have to write

.css({display: 'none' })

twice? i tried the following but it obviously does not work

angular.element(document.getElementById('cont_' + i)).
angular.element(document.getElementById('resize_' + i)).css({ display: 'none' })

also, i need them to be with separate id because i use them individually in other places.

any ideas,

thanx,

2 Answers 2

1

You can use document.querySelectorAll, thus:

angular.element(document.querySelectorAll('#cont_' + i, '#resize_' + i)).css({display: 'none' })
Sign up to request clarification or add additional context in comments.

1 Comment

In fact, the .css () function is from angular.element
0

Use css dynamic selectors. Just get a parent element and then write div[id^=cont_] and write css there.

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.