How do I clear a search box with an 'x' in bootstrap 3?

前端 未结 9 1536
情歌与酒
情歌与酒 2020-12-12 10:44

Having some trouble with bootstrap, so some help would be awesome. Thanks

What I would like:(top part)

\

9条回答
  •  执笔经年
    2020-12-12 11:25

    AngularJS / UI-Bootstrap Answer

    • Use Bootstrap's has-feedback class to show an icon inside the input field.
    • Make sure the icon has style="cursor: pointer; pointer-events: all;"
    • Use ng-click to clear the text.

    JavaScript (app.js)

    var app = angular.module('plunker', ['ui.bootstrap']);
    
    app.controller('MainCtrl', function($scope) {
    
      $scope.params = {};
    
      $scope.clearText = function() {
        $scope.params.text = null;
      }
    
    });
    

    HTML (index.html snippet)

          

    Here's the plunker: http://plnkr.co/edit/av9VFw?p=preview

提交回复
热议问题