How to add the links inside the select box
Home » Blog » Javascript » How to add the links inside the select box

How to add the links inside the select box

Updated:   Javascript 1 min read

Your support helps keep this blog running! Secure payments via Paypal and Stripe.


We all know that we can not add the links inside the <option> in the select box. Today I gonna share one simple trick with pure javascript.

Let’s say you want to add the links inside the <option> like this.

<select class="menus">
    <option value="Home"><a href="home.php">Home</a></option>
    <option value="About"><a href="about.php">About</a></option>
    <option value="Contact"><a href="contact.php">Contact</a></option>
</select>

Of cause, it is not working.

Here is the correct one with the javascript.

<select class="menus" onchange="location = this.value;">
 <option value="Home.php">Home</option>
 <option value="About.php">About</option>
 <option value="Contact.php">Contact</option>
</select>

What we are doing here. We just add the links into the value attribute. Then we add the onchange event. Finally, we add the javascript code for linking to the URL you want.

This method is very simple and we don’t need to include any plugins at all.


Your support helps keep this blog running! Secure payments via Paypal and Stripe.


Senior WordPress Developer (Freelancer)

Senior WordPress Developer (Freelancer)

I’m a professional WordPress and WooCommerce developer based in Chiang Mai, Thailand, with over a decade of experience creating fast, secure, and scalable websites. From custom themes and plugins to full WooCommerce stores, I help businesses build a strong and reliable online presence. Need a freelance WordPress developer you can count on? View my portfolio or get in touch to discuss your project.