JQuery: passare url da un link all'altro

JQuery: passare url da un link all'altro:




Ad esempio: 
 <a href="www.target1.it" id="1"> e  <a href="VUOTO" id="2">




<!DOCTYPE html>
<html lang="it-IT" >
<head>
<meta charset="UTF-8" />           
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<style type="text/css">
.box{width:200px;height:100px;margin:10px;}
.box1{background:red;}
.box2{background:green;}
.box3{background:yellow;}

</style>

</head>
<body>
               
                            <script type="text/javascript" language="javascript">
                                <!--
                                $(document).ready(function() {           
                                           
                                            var toks = $("#codice").attr('href');
                                           

                                            $("#codice2").attr('href', toks);
                                           
                                            $(".target").attr('href', toks);
                                           
                                    });   
                            </script>   
                           
                   

<div class="box box1"> LINK 1 ORIGINE<a href="www.target1.it" id="codice">link 1</a>  </div>
<div class="box box2"> LINK 2 TARGET SU ID <a href="www.target2.it" id="codice2">link 2</a>  </div>

<div class="box box3"> LINK 3 TARGET SU CLASSE <a href="www.target3.it" id="codice3" class="target" >link 3</a> </div>
<div class="box box3"> LINK 4 TARGET SU CLASSE <a href="www.target4.it" id="codice3" class="target" >link 4</a> </div>





                   
    </body>
</html>   

Commenti