In the production of the province drop-down list, we often encounter a large number of provinces continue to copy and paste problems, such as Baidu to such a fill in the Province information table:
It contains a lot of data and content, this time to a copy and paste is very cumbersome, so inspired by colleagues I wrote a simple way for everyone to use.
//Navigate to your tablevarTable = $ (". Table-view"));//defining the Receive stringvarStr= "";//iterate through the contents of a table, assigning a value to a stringTable.find ("tr"). each (function(){//Defining temporary variablesvarTdarr = "";varTdarr = "";//find the data content, note that text () only gets the text content under the current element, and innerHTML can get all the content including the tagTdarr = $ ( This). Find ("TD"). EQ (0). Text (). Replace (/[\r\n]/g, ""); Tdarr= $( This). Find ("TD"). EQ (1). Text (). Replace (/[\r\n]/g, "");//Stitching Stringsstr+= ' <option value = "' +tdarr + '" > ' +tdarr+ ' </option> ';})
Province name Reference Link: province name
After the output is as follows:
12, (expand) Get the province table, fill in the drop-down list box simple JS