JQuery каждый объект Json

Ваш пример кода является неправильным. Это работает:

import datetime

datetime.datetime.strptime("21/12/2008", "%d/%m/%Y").strftime("%Y-%m-%d")

вызов к strptime () анализирует первый аргумент согласно формату, указанному во втором, таким образом, те два должны соответствовать. Затем можно назвать strftime () для форматирования результата в желаемый заключительный формат.

20
задан nickf 14 October 2009 в 22:48
поделиться

3 ответа

Inside the function provided to each, this refers to the current element. Try this:

$.each(result.GroupList, function() {
    $('#myTable > tbody').append(
        '<tr><td>'
        + this.userName
        + '</td><td>'
        + this.count +
        '</td></tr>'
    );
});

If that doesn't work for you, it may have something to do with this: $('#myTable > tbody'), considering that there is no tbody element. I believe that Internet Explorer will automatically create one but the other browsers won't. Check $.support.tbody to see if the browser does that for you.

42
ответ дан 29 November 2019 в 23:27
поделиться

I noticed your table does not actually have a tbody element. This could be part of your issue.

$('#myTable > tbody').append.....

<table id="myTable" border="2" cellpadding="3" cellspacing="3">
</table>

I would also suggest that you create a string in your $.each() loop and then do the following after your each loop:

$('#myTable > tbody').html(string);

This will reduce the overhead of appending each time you iterate over the array.

3
ответ дан 29 November 2019 в 23:27
поделиться

Когда я использовал $ .each (), я использовал функцию (i, item), где i - целое число, указывающее индекс, а item - это фактический объект. Вот как документация показывает, что это делается - метод описан как обратный вызов функции (indexInArray, valueOfElement).

2
ответ дан 29 November 2019 в 23:27
поделиться
Другие вопросы по тегам:

Похожие вопросы: