Using jQuery, from HTML
"hoge1 hoge1_2 quantity: 1, hoge2 hoge2_2 quantity: 2, hoge3 hoge3_2 quantity: 3..."
Repeat for class="list_" minutes in class="boxlist_"
I would like to pick up only certain attributes, concatenate strings, and return the return value.
Also, regarding the quantity,
in select
I would like to get only those with selected elements as values.
▼ HTML
<table class="boxlist_">
<tbody>
<tr class="list_">
<td class="name_">
<div class="name_">
<div class="name1_"><a href="/hoge/"title="hpge">hoge1</a>>/div>;
<span class="name2_">hoge1_2</span>
</div>
</td>
<td class="price_box_"nowrap="nowrap">
<p class="qty_"> quantity <br>
<select name="qty1"><option value="1">1</option value="2">2>/option value="3">3>/option>>>>4="4">"
</select>
</p>
</td>
</tr>
<tr class="list_">
<td class="name_">
<div class="name_">
<div class="name2_"><a href="/hoge/"title="hpge">hoge2</a>>/div>;
<span class="name2_">hoge2_2</span>
</div>
</td>
<td class="price_box_"nowrap="nowrap">
<p class="qty_"> quantity <br>
<select name="qty1"><option value="1">1;/option value="2" selected="">2>/option value="3">3>/option value="3">3>/option>4>">vout;4>al"
</select>
</p>
</td>
</tr>
<tr class="list_">
<td class="name_">
<div class="name_">
<div class="name3_">a href="/hoge/"title="hpge">hoge3</a>>
<span class="name2_">hoge3_2</span>
</div>
</td>
<td class="price_box_"nowrap="nowrap">
<p class="qty_"> quantity <br>
<select name="qty1"><option value="1">1</option value="2">2>/option value="3" selected="3<3</option>4>>>vout;4>=">4>vout.
</select>
</p>
</td>
</tr>
</tbody>
</table>
▼Trying js
function(){
var result=[];
jQuery(".boxist_tr.list_").map(function(index,Element){
variableName=jQuery(Element).find('td.name_div.name_').text().replace(/\s+/g, ");
varitemQty=jQuery(Element).find('p.qty_select option: selected').attr('value');
result.push(itemName+"quantity:"+"+itemQty).join(","); // Add to Array
return result;
});
// console.log(result);
}
In this case, the value is [ ] and
I can't get the desired value.
I would appreciate it if you could let me know how to correct it.
Thank you for your cooperation.
The first mistake is
jQuery(".boxist_tr.list_").map(function(index,Element){
.boxist
→.boxlist
.
result.push(itemName+"quantity:"+"+itemQty).join(","); // Add to Array
Since map()
, there is no need to push() in the callback, and the timing of join()
is strange.
function(){
let result=jQuery(".boxist_tr.list_").map(function(index,element){
letitemName=jQuery(element).find('td.name_div.name_').text().replace(/\s+/g, ");
let itemQty=jQuery(element).find('p.qty_select option: selected').attr('value');
return`${itemName} quantity:${itemQty}`;
}).get().join(",");
return result;
}
606 Uncaught (inpromise) Error on Electron: An object could not be cloned
567 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
597 GDB gets version error when attempting to debug with the Presense SDK (IDE)
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.