Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change all links at once

Is there any way i can change all links at once under option tag?
For Example:

<select size="1" name="links" onchange="window.location.href=this.value;">
<option value=" http://website.com/1001/">Blue</option>
</select><br>

 <select size="1" name="links" onchange="window.location.href=this.value;">
<option value=" http://website.com/2001/">Red</option>
</select><br>

<select size="1" name="links" onchange="window.location.href=this.value;">
<option value=" http://website.com/3001/">Green</option>
</select>

.... And so on around 100 links .
Now i want to change link website.com to m.website.com furthur link remains same. Like m.website.com/1001 , m.website.com/1002

like image 973
wordpress user Avatar asked Jan 14 '16 04:01

wordpress user


1 Answers

try this :

$(function(){ 
  $('select[name="links"] option').each(function(){
   var val=$(this).val();
   val=val.replace('http://','http://m.');
   $(this).val(val);
  });
});

Demo

like image 75
Mohit Kumar Avatar answered Oct 25 '22 19:10

Mohit Kumar