Link transfers attribute content to player

<a href="#" data-url="http://stackoverflow.com"> 

And the player is already displayed as

 $('.jp-image').html('<a href="'+$(this).data('url')+'">' + '<img src="'+$(this).data('image')+'" alt=""></a>'); 

Also the link with an excess slash in the beginning of the address turns out

 <a href="/http://stackoverflow.com"> 

How to remove this slash? The address is incorrect.

 http://stackoverflow.com/http://stackoverflow.com 
  • More information, these are just pieces of code that don't say anything, what is the element with the jp-image class? Where is he even gone? :) - Shnur
  • There is nothing else. This div is inserted by the script link <div class="jp-image"></div> - steep
  • How does the jQuery code you cite run? What actions take place to launch it, moreover, you and the <a> tag are not closed, these are just torn pieces from the code for which it is not possible to say anything. - Shnur
  • Moreover, this code is also a bunch of errors. - Shnur
  • What does not have a closed tag, it's just an example. If I give all the code, then nothing will be clear. - steep

1 answer 1

There is a <base href = "/" /> tag when it is used - for links with a relative path, the value from this tag is substituted. https://jsfiddle.net/8cxwnvpz/

 <base href="http://artlebedev.ru"/> <a href="kovodstvo">Руководство</a> 

or here https://jsfiddle.net/w25kafuf/

 <base href="/"/> <a href="user/login/" target="_blank">Log in</a> 
  • I do not have base links. But now I’ll try to put it the other way around to get the address of the site, - steep
  • I did not understand, I only have a full path, then it will not work - steep
  • I thought it would turn out that way, but I don’t want to make a relative path <base href="http://artlebedev.ru"/> <a href="kovodstvo">Руководство</a> - steep
  • Although it is possible to try with an empty <base href=""> But only if it even turns out, is there some option ahhh. - steep