简体   繁体   中英

How do I copy a link from one place on the page into another div

I've a Joomla website with K2 items and pagination.

I show the pagination on the bottom of page, and this will generate links to previous and next article on the bottom of the page (and it assign each link a specified css class).

I would ask if is there a (maybe php?) code to show these links also on the right bar of the website (so using a module, cause I've a plugin to insert php or javascript inside modules).

How can I copy that links showed on the bottom of page, into another place of the website?

You can get the href of the specific a tag using jquery's Attr .

A demo is shown below:

 var x = $('.prev').attr("href"); $('nav div:first-child').text("Prev = " + x); var y = $('.next').attr("href"); $('nav div:last-child').text("Next = " + y); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <nav> <div>Prev:</div> <div>Next:</div> </nav> <a href="www.facebook.com" class="prev">link prev</a> <a href="www.google.com" class="next">link next</a> 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM