Cara menggunakan javascript onclick enable input

Apa itu title[]? Yakni salah satu event yang sering digunakan pada saat membangun suatu aplikasi yang berfungsi untuk memproses suatu perintah ketika user melakukan interaksi pada suatu element tertentu. Dengan kata lain, ketika user menekan, baik itu tombol klik pada mouse maupun tauchpad, pada suatu element tertentu. Event ini akan berfungsi apabila disisipkan pada suatu element tertentu untuk memanggil function yang telah dibuat. Event title[] ini sudah support pada semua browser terbaru.

Penulisan event title[] ini juga terdapat berbagai macam cara dan kesemuanya merujuk pada fungsi yang telah dituliskan pada javascript. Beberapa cara penulisannya adalah sebagai berikut :

  • Pada HTML
    Event ini disematkan pada element HTML. Apapun bentuknya, boleh pada button ataupun text yang berada diantara tag. Berikut adalah cara penulisannya :
     
    
    
    
    
    Klik
    
    
    Klik
     
  • Pada Javasript
    Pada cara ini, event title[] ditulis secara langsung pada JavaScipt. Jadi, event  title[] ini berada pada code dalam Javascript dan melakukan proses yang diinginkan. Berikut cara penulisannya :
     
    
    

    Klik.

     

    Setelah code diatas tertulis, pad bagian bawah kita tulis kode JavaScript untuk memanggil nama id demo pada element di atas. Begini cara penulisannya.

     
    //cara penulisan pertama-->
    document.getElementById["demo"]. title = function[] {
    	fungsinya[]
    };
    //cara penulisan kedua menggunakan jquery-->
    $[document].on['click','#demo',function[event]{
    	fungsinya[]
    };
     

See the Pen
event onClick[] by codenya.com [@codenyacom]
on CodePen.

Kesemua code di atas, merujuk pada 1 nama function, yakni fungsinya[] pada javascript. Sehingga kita tinggal membuat function di dalam javascript. Begini contoh penulisannya :

 

function fungsinya[]{
	//tulis proses yang diinginkan di sini
}

 

Nah, sekarang tinggal Kamu berkreasi ingin melakukan proses apa pada function fungsinya[]. Sangat mudah bukan? Giliran Kamu untuk mencobanya sobat!!!

  • Home
  • Guides
  • Reference
  • Support

Stay organized with collections Save and categorize content based on your preferences.

Complete the steps described in the rest of this page to create a simple JavaScript web application that makes requests to the Google Calendar API.

Prerequisites

To run this quickstart, you need the following prerequisites:

  • Python 2.4 or greater [to provide a web server]
  • A Google Cloud Platform project with the API enabled. To create a project and enable an API, refer to Create a project and enable the API
  • Authorization credentials for a desktop application. To learn how to create credentials for a desktop application, refer to Create credentials.
  • A Google account with Google Calendar enabled.

Step 1: Set up the sample

To set up the sample:

  1. In your working directory, create a file named index.html.
  2. Include the following code in index.html:

  3. In the code, replace with the client ID you created as a Prerequisite for this quickstart.

  4. In the code, replace with the API key you created as a Prerequisite for this quickstart.

Step 2: Run the sample

To run the sample:

  1. Start the web server using the following command from your working directory:

Python 2.x

python -m SimpleHTTPServer 8000

Python 3.x

python -m http.server 8000

  1. In your browser, navigate to //localhost:8000.

  2. [optional]. If this is your first time running the sample, the sample opens an OAuth consent screen prompting you to authorize the app to access your data on your behalf:

    1. If you are not already signed in to your Google account, you are prompted to sign in. If you are signed in to multiple Google accounts, you are asked to select one account to use for authorization.

    2. Click Accept. The app is authorized to access your data.

  3. The sample executes.

If you have problems, refer to the Troubleshoot the sample section.

Troubleshoot the sample

This section describes some common issues that you can encounter while attempting to run this quickstart.

Error: origin_mismatch

This error occurs during the authorization flow if the host and port used to serve the web page doesn't match an allowed JavaScript origin on your Google Developers Console project. Make sure you set an authorized JavaScript origin and that the URL in your browser matches the origin's URL.

idpiframe_initialization_failed: Failed to read the 'localStorage' property from 'Window'

This error occurs when 3rd party cookies and data storage aren't enabled in your browser. These options are required by the Google Sign-in library. For further information, refer to 3rd party cookies and data storage.

idpiframe_initialization_failed: Not a valid origin for the client

This error occurs when the domain registered as a Prerequisite doesn't match the domain being used to host the web page. Ensure that the origin you registered as a Prerequisite matches the URL in the browser.

This app isn't verified

If the OAuth consent screen displays the warning "This app isn't verified," your app is requesting scopes that provide access to sensitive user data. If your application uses sensitive scopes, your app must go through the verification process to remove that warning and other limitations. During the development phase, you can continue past this warning by selecting Advanced > Go to {Project Name} [unsafe].

Further reading

For further information on the APIs used in this quickstart, refer to the Google API Client Library for JavaScript section of GitHub.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-07-29 UTC.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]

Bài mới nhất

Chủ Đề