append - How to display the title attribute of an input field in a Jquery map function -


i have following script appends list of input values textarea.

<script>    function showvalues() {        var fields = $(".content :input").serializearray();        var tokens = jquery.map(fields, function(field) {                return (field.value) ? (field.value + ' ' + field.name) : null;            });        $("#contentlist_copy").val(tokens.join(', '));    }       $("input").change(showvalues);       showvalues();      </script> 

instead of displaying name attribute field.name of returned field, i'd display title attribute. i've tried few tricks, nothig giving.

i should point out follow-up question topic:how hide appended input names when value empty

the title attribute isn't stored in serializearray. you'll have use .map directly on $(".content :input")

function showvalues() {    var tokens = $(".content :input").map(function() {        return (this.value) ? (this.value + ' ' + this.title) : null;    }).get();    $("#contentlist_copy").val(tokens.join(', ')); } $("input").change(showvalues); showvalues();      

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -