星期一, 7月 07, 2014

[AngularJS] 實作自動選取的directive

實作自動選取的directive範例

HTML

 <input type="text" value="test" select-on-click />

JS

module.directive('selectOnClick', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            element.on('click', function () {
                this.select();
            });
        }
    };
});

http://stackoverflow.com/questions/14995884/select-text-on-input-focus-in-angular-js

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails