Mehul Kuriya Mehul Kuriya - 8 months ago 36
jQuery Question

Jquery change extension on link on fly

I have set of link in so many pages.

<li> <a href="someurl/somefile.html"> Some file </a> </li>
<li> <a href="someurl/somefile1.html"> Some file1 </a></li>
<li> <a href="someurl/somefile2.html"> Some file2 </a></li>

<a href="someurl/someotherfile.html"> Some Other file </a>
<a href="someurl/someotherfile1.html"> Some Other file1 </a>

Now, I wana change html to php extension. without modifying the php code.

I have try following code but it does not work.

$('a').each(function() {
$(this).html( $(this).html().replace( ".php", '.html' ) );

Any help will be appriciated .


Following code will solve your problem. Ii will change .html to .php without change any url.

Please try following code.

$('a').each(function() {
   var curhre= $(this).attr('href');
   text = curhre.replace(".html", ".php");