Demo

HTML:

<body>
    <button>Custom</button>
    <span>From:
        <input type="text"  />
    </span>
    <span>To:
        <input type="text"  />
    </span>
</body>

CSS:

span {
    display: none;
}
.show {
    display: inline-block;
}

JS:

$("button").on("click", function () {
    $("span").toggleClass("show");
});

Demo

Method one

HTML:

<body ng-app="ngToggle">
    <div ng-controller="AppCtrl">
        <button ng-click="toggleCustom()">Custom</button>
        <span ng-hide="custom">From:
            <input type="text"  />
        </span>
        <span ng-hide="custom">To:
            <input type="text"  />
        </span>
        <span ng-show="custom"></span>
    </div>
</body>

JS:

angular.module('ngToggle', [])
    .controller('AppCtrl',['$scope', function($scope){
        $scope.custom = true;
        $scope.toggleCustom = function() {
            $scope.custom = $scope.custom === false ? true: false;
        };
}]);

Method two

HTML:

<body ng-app="ngToggle">
    <div ng-controller="AppCtrl">
        <button ng-click="custom=!custom">Custom</button>
        <span ng-hide="custom">From:
            <input type="text"  />
        </span>
        <span ng-hide="custom">To:
            <input type="text"  />
        </span>
        <span ng-show="custom"></span>
    </div>
</body>

JS:

angular.module('ngToggle', [])
    .controller('AppCtrl',['$scope', function($scope){
        $scope.custom = true;
}]);
 

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2021-09-20
  • 2021-08-17
  • 2021-06-23
  • 2021-12-15
猜你喜欢
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2021-04-06
相关资源
相似解决方案