使用jQuery收集join concatenate打印显示每个div的内容值html文本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用jQuery收集join concatenate打印显示每个div的内容值html文本相关的知识,希望对你有一定的参考价值。
/** v0.1 - 20081028 - thanks to Christian Oudard & Shog9 on StackOverflow - http://bit.ly/aqEKhO v0.2 - 201007100030 - brandonjp **/ /** specify an element, then collect the contents from each one on the page then concatenate all those contents and display them in one list/string **/ // first, a variable for the element we want to collect var theElements = $("td.fonta"); // second, a variable for the separater we want between each // by default the 'join()' method returns comma separated values var betweenEach = ""; // create the empty array where we'll store everything var allCurries = []; // now we actually get the elements we want and for each theElements.each(function() { // grab our array and push each element's text() into it allCurries.push( $(this).text() ); }); // create a new object that joins everything in our array var allTogether = allCurries.join(betweenEach); // inject, print, show, alert or display our final list $('div#output').replaceWith(allTogether); /** or the short version **/ var arr = []; $('td').each(function() { arr.push($(this).text()); }); alert(arr.join(''));
以上是关于使用jQuery收集join concatenate打印显示每个div的内容值html文本的主要内容,如果未能解决你的问题,请参考以下文章
使用 wpdb prepare 安全地收集带有“join”的“where”子句数组