How to get a DOM using dojo by the tag name?
I have a html code like this :
<select name="limit">
<option value="10">10</option>
<option value="25">25</option>
</select>
in jQuery framework, it will be:
var limit = $("select[name=limit]");
...but in Dojo framework, what must I do ?
Should I use dojo.query("select[name=limit]") ?
Yes, dojo.query("select[name=limit]") is correct, but remember that in dojo, it returns an array (even if there is only one match in the DOM). So to get the first (and possibly only) match, you need select the first element:
var limit = dojo.query("select[name=limit]")[0];
Consider you have an input field named 'myInput'. <input id="1" name="myInput" />
For getting a value (or other attribute) use following: ([0] define index of your component)
dojo.query('[name="myInput"]').attr('value')[0];
If you want to set some value, you will do this:
dojo.query('[name="myInput"]')[0].value = 'newValue';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With