1

I have a bunch of inputs e.g:

<div class="token-list">
  <input type="hidden" name="tokens[]" value="token1" />
  <input type="hidden" name="tokens_text[]" value="token1_text" />
  <input type="hidden" name="tokens[]" value="token2" />
  <input type="hidden" name="tokens_text[]" value="token2_text" />
  <input type="hidden" name="tokens[]" value="token3" />
  <input type="hidden" name="tokens_text[]" value="token3_text" />
  <input type="hidden" name="tokens[]" value="token4" />
  <input type="hidden" name="tokens_text[]" value="token4_text" />
  <input type="hidden" name="tokens[]" value="token5" />
  <input type="hidden" name="tokens_text[]" value="token5_text" />
</div>

Is it possible to select just the ones with the name 'tokens' in CSS?

I was hoping to do something like input[name~=hosts[]] (This isn't working - I assume because of the square brackets in the name).

2
  • 1
    if it's the real html you can try :nth-child(2n) or why not :odd or :even Commented Jun 3, 2013 at 22:10
  • +1 for :nth-child(2n) but this won't work for me - This is a snippet of the code Commented Jun 3, 2013 at 22:16

1 Answer 1

3
[name="tokens[]"] {
    background: honeydew;
}

http://jsfiddle.net/2pUgY/3/

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

1 Comment

Attribute selectors are awesome. I've found Chris Coyier's post on them to be invaluable.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.