I have the following line:
<a href="page.php">Mt 5: 2</a>
And I use jquery code to echo (match) whatever between the > <
brackets and makes the link as follows:
<a href="page.php?q=Mt 5: 2">Mt 5: 2</a>
Now I need the link to be as follows:
<a href="page.php?book=Mt&chapter=5&vmin=2">Mt 5: 2</a>
The code I am currently using to match all is:
$(document).ready(function() {
$("a[href='page.php']").each(function(index, element){
href = $(element).attr('href');
$(element).attr('href', href + "?q=" + $(element).text());
});
});
So I need to divide whatever between the > <
to three sections respectively:
- adds Mt to ?book= → ?book=Mt
- adds 5 to &chapter= → &chapter=5
- adds 2 to &vmin= → &vmin=2