jquery 1

by ebaloSnositelXX

JavaScript

//значение аттрибута content у элемента <meta property="og:image" content="...">
$("meta[property='og:image']").attr("content");

//список ссылок на все картинки на странице размером больше чем 100×100
$("body img").map(function () {
    var $that = $(this);
    if ($that.width() > 100 &&
        $that.height() > 100) {
        return $that.attr("src");
    }
});

//имена всех элементов форм (textarea, input, button, select) на странице в алфавитном порядке
$("body form textarea, input, button, select [name]")
    .sort(function (a, b) {
    if (a.getAttribute("name") > b.getAttribute("name")) {
        return 1;
    } else if (a.getAttribute("name") < b.getAttribute("name")) {
        return -1;
    } else {
        return 0;
    }
}).map(function () {
    return $(this).attr("name");
});

//список всех постов в формате "Название поста", число просмотров, число комментариев, ссылка
(function () {
    var result = [];
    var $postList = $(".post");
    $postList.map(function () {
        var elem = $(this);
        var data = {
            "postName": null,
            "views": null,
            "comments": null,
            "ref": null
        };
        var $postTitle = elem.find(".post__title_link");
        data.postName = $postTitle.html();
        data.views = elem.find(".views-count_post").html();
        var $comments = elem.find(".post-comments__link");
        if ($comments.has("span").length) {
            $comments = 0;
        } else {
            $comments = $comments.html();
        }
        data.comments = $comments;
        data.ref = $postTitle.attr("href");
        result.push(data);
    });
    console.log(result)
}());

//допиши к заголовкам постов в скобках число просмотров
(function () {
    var $postList = $(".post");
    $postList.map(function () {
        var $elem = $(this);
        var $title = $elem.find(".post__title_link");
        var views = $elem.find(".views-count_post").html();
        views = " (" + views + ")";
       ...