JS Custom Button Style

  • Last update:November 26, 2020
  • I. Overview

    In applications, it is often necessary to modify the style of a button. In addition to modifying the CSS style, you can realize custom button style by JavaScript codes.

    This article uses several examples to show how to change the button style through JavaScript , as shown in the following figure:

    1606375585720526.gif

    II. Example

    2.1 Report design

    Add button widgets to cells A1~A7, the name of the button in A7 is BUTTON, as shown in the figure below:

    1606375585431997.png


    2.2 Add event

    Add Click events to A1~A6 respectively.

    1606375585135129.png

    The JS code in the event is as follows:

    1) Cell A1

    $('.fr-btn-text').eq(6).css('color','red');//Make the color of button name in A7 turn red

    2) Cell A2

    $('#fr-btn-BUTTON').css('text-align','left');//Make the button name in A7 be displayed on the left

     3) Cell A3

    $('.fr-btn-text').eq(6).css('font-size','20px'); 
    $('.fr-btn-text').eq(6).css(' height','25');
    //Make the font of button name in A7 become 20px, and the text height defaults to 16px. If the text size exceeds the text height, the display will be incomplete. You need to adjust the text height of the button

     4) Cell A4

    $('.fr-btn-up').eq(6).css('border-radius','20px');//rounded border

     5) Cell A5

    $('.fr-btn-text').eq(6).css('font-style','italic');//Make the font of button name in A7 italic

     6) Cell A6

    $('.fr-btn-up').eq(6).css('height','20'); $('.fr-btn-up').eq(6).css('width' ,'50');//Make the background of the button in A7 shrink


    2.3 Effect

    Save the report, click Data Entry Preview, and the effect is as shown in the figure below:

    1606375585331141.gif

    Note: Mobile terminal is not supported.

    III. Completed Template

    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    7s后關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy