I have a select box with few options. eg
<select>
<option value="India">India</option>
<option value="Usa">Usa</option>
</select>
I have href element as below and i want the value of selected option in select box to be appended to the href link, while clicking the href element. lets say name=India.
eg <a href="http://localhost:8080/country?name=">Visit Country</a>
$('select').on('change', function() {
var old_href = $('a').attr('href'),
new_href = old_href.split('=')[0] + '=' + this.value;
$('a').attr('href', new_href);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.