Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

click specific option using javascript or jquery

I tried googling this but I am getting only on event trigger searches instead of what I am looking for.

I want to dynamically click on any of the options in the select dropdown by using the value or the text if possible.

HTML

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<select id="certainspamselectid" name="certainspamselect" style="margin-left: 165px;">
   <option value="0">permanently deleted</option>
   <option value="4">moved to admin quarantine</option>
   <option value="1">moved to junk email folder</option>
   <option value="5">delivered to inbox with tag</option>
   <option value="2">delivered to inbox</option>
</select>

I am not sure if I need to use something with $("#certainspamselectid").click..... but I am not sure what to use after click. I would have tried more things but my google searches keep pinpointing me for on event triggers when I just want to click on one of these options using either JS or jQuery.

>Solution :

I have read your problem and honestly, I can’t understand what you want exactly.
However, it looks like you want to select some certain option of the select dropdown.
If that’s right, you don’t need to call some kind of click function.

You can do it easily with jQuery.

For example, imagine that you are going to select third option – "moved to junk email folder". Then you can select it by code like below.

$("#certainspamselectid").val(1);

If my answer is not enough for you, let me know detail of your problem.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading