I have the following situation, I have two h1 in different places in the web site, I would like to click the value of one h1, it would pass to the other.
I have the following situation, I have two h1 in different places in the web site, I would like to click the value of one h1, it would pass to the other.
function Capture(){
var _text = $('#primeiro_h1').html();
$('#segundo_h1').html(_text);
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><h1id="primeiro_h1">Seu primeiro H1</h1>
<h1 id="segundo_h1">Seu segundo H1</h1>
<a href="javascript:;" onclick="Capture();">Click para capiturar</a>
Now if the idea is to make the value change as it is clicked on an element it would look like this:
$('#bto_click').click(function(){
var _text = $('#primeiro_h1').html();
$('#segundo_h1').html(_text);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><h1id="primeiro_h1">Seu primeiro H1</h1>
<h1 id="segundo_h1">Seu segundo H1</h1>
<a href="javascript:;" id="bto_click">Click para capiturar</a>
Any doubt just scream !!!!
Here is the script to change values between two h1:
$(document).ready(function() {
$('h1').click(function() {
var prevH1 = $(this).prev('h1').html();
var nextH1 = $(this).next('h1').html();
var thisH1 = $(this).html();
if (nextH1) {
$(this).html(nextH1);
$(this).next('h1').html(thisH1);
} else {
$(this).html(prevH1);
$(this).prev('h1').html(thisH1);
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>Lorem Ipsum</h1>
<h1>Título</h1>