I'm trying to capture the values of pairs of textboxes on my page.
I am capturing them, but it's not exactly working the way I'd want it to as I am getting duplicate data.
Here's my HTML code:
<div id="links">
<div id="group1">
<input type="text" name="linkTitle" value="Google">
<input type="text" name="linkURL" value="www.google.com">
</div>
<div id="group2">
<input type="text" name="linkTitle" value="Yahoo">
<input type="text" name="linkURL" value="www.Yahoo.com">
</div>
</div>
<div>
<input id="btnSaveLinks" type="button" value="Save">
</div>
And here is the javascript:
$("#btnSaveLinks").on('click', function() {
$('#links input[type=text]').each(function () {
var title = $(this).attr("value");
var url = $(this).attr("value");
console.log('title: ' + title);
console.log('url: ' + url);
});
});
title: Google
url: Google
title: www.google.com
url: www.google.com
title: Yahoo
url: Yahoo
title: www.yahoo.com
url: www.yahoo.com