I want to create a jQuery statement that looks like this:
$('.total_999').html("something");
However, 999
comes from variable called storeNo
.
How can I construct this statement dynamically?
$(+ storeNo '总_。')。html的( “东西”);
total_999 in your example is a class. Since it appears to be unique (or likely so), then it should probably be the id, and use a more generic class.
for example:
<div id="total_999" class="total">...</div>
then you can use the id, or the class to refer to the element
$('#total_'+storeNo); //get the element
or
$('.total'); //get all of the totals
A more complete example might be:
function setTotal(storeNo, total) {
$('#total_'+storeNo).html(total);
}
setTotal(999,'$1,276');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.