0

I have code:

<select multiple="multiple" id="id_browser" name="browser">
<option value="1">Chrome</option>
<option value="2">Mozilla Firefox</option>
</select>

<select id="id_type" name="type">
<option value="max">Max</option>
<option value="min">Min</option>
</select>

And I'm using this lib: http://wenzhixin.net.cn/p/multiple-select/docs/#methods

following the docs:

<script>
$('select').multipleSelect();
</script>

But this changes both field. How can I use this lib to only 'id_browser select'?

1
  • 1
    The id attribute is unique, so pass that as your selector like $('#id_browser').multipleSelect() Commented Sep 18, 2015 at 18:13

1 Answer 1

1

Selection inside of a jQuery item is the same as selecting using CSS.

So in this case, try something like

$('#id_browser select').multipleSelect();

This will select elements that have an id (specified by a #) of id_browser, then look for any elements inside the #id_browser element that are of the select type (specified with no special characters before select).

Here's a quick rundown of the types of CSS selectors:

#id
.class
type

Here's a great reference on CSS selectors from Mozilla: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started/Selectors

There's also an awesome page here that details complex selectors, which let you do almost anything with some advanced selector patterns: http://learn.shayhowe.com/advanced-html-css/complex-selectors/

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.