无法使用jQuery

时间:2016-08-17 18:51:20

标签: javascript jquery html css

好像我的JavaScript没有听我说。我只是想设置所有锚点'高度等于这些锚的最高高度。

HTML

<div class="col-md-4 col-sm-6 col-xs-12 product-items" ng-repeat="products in products">
    <div class="product">
        <h3>{{products.title}}</h3>
        <img ng-href="" ng-src="{{products.thumbimg}}" alt="{{products.imgalt}}">
        <a href="#">{{products.link}}</a>
        <p>{{products.price | currency : ""}} BGN</p>
        <p>Free Shiping</p>
        <button>BUY</button>
    </div>
</div>

JS

(function () {
    var app = angular.module("app", []);
    var MainController = function ($scope, $http, $filter) {
        ...
        ...
        ...
        /* Jquery */
        var maxHeight = 0;
        $("div .product a").each(function () {
            if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
        });

        $("div .product a").height(maxHeight);


    };
    app.controller("MainController", MainController);
} ());

如何在h1,h2或h3 html元素上设置相等的高度

1 个答案:

答案 0 :(得分:0)

<a>元素是内联元素,您无法使用CSS中的height更改内联元素的高度。您必须通过将此CSS代码添加到页面来将它们更改为内联块元素:

a {
  display: inline-block;
}