I have a simple select element that I want to set the value for using dojo. So when the page loads, I’d like some value to be selected. I am having the hardest time trying to perform that action with dojo. I’m not sure if it’s because of my lack of understanding (I come from a jQuery world and now have been forced to use dojo at work) but every search comes up with using dijit.form.Select. However, what if I don’t want to use their custom select element. I just want to simply manipulate the contents of the plain select.
I know with jQuery I would do something like
$(“#select option[value=’3′]”).attr(‘selected’, ‘selected’);
But I can’t seem to figure out how to perform this with dojo.
I’ve been experimenting with this for a while, and I just found how you can do it. It’s basically a mix between Dojo’s functionality and plain javascript.
Make sure you include the
[0], becausedojo.queryreturns an array.