jquery - Using map to get all but last in data array -


the following iterates on <th> elements , creates array of text, each array entry surrounded <span> tags.

but, don't ever need content of last <th> element - there way omit function?

var newcontent = $('#tablehead').find('th').map(function(){     return '<span>' + $(this).text() + '</span>'; }).get(); 

try using .slice(0, -1)

var newcontent = $('#tablehead').find('th').slice(0, -1).map(function(){     return '<span>' + $(this).text() + '</span>'; }).get(); 

demo: http://jsfiddle.net/r6cpx/


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -