Below, I am trying to iterate through each attribute in an input element. It isn't working and I'm not sure why. Is this an incorrect use of the object named input? How do I change this?
<script>
$('form.trade').submit(function(e) {
e.preventDefault();
input=$(this).find(':input:first');
value='';
$.each(input.attributes, function(i, attrib){
if (attrib.name!='type'){
value +=attrib.name + ":" + attrib.value + ";";
}
});
});
</script>
<form class="trade" id="24243">
<input type="hidden" available="4" pid="24243" cardname="something" yay="blah">
Available: <p class="available">4</p>
<input type="submit" value="add card">
</form>
<br/>
<form class="trade" id="24245">
<input type="hidden" available="7" pid="24243" cardname="somethik" yay="blakk">
Available: <p class="available">7</p>
<input type="submit" value="add card">
</form>