click anywhere in this div


Mark it as Best Answer, if it helps", "upvoteCount": 2, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4YG0SAN", "datePublished": "2016-05-05T08:37:37.000Z", "author": { "@type": "Person", "name": "Mohammed Rizwan", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DGgW3QAL", "affiliation": { "@type": "Organization", "name": "Porter" } } }, "suggestedAnswer": [] } } Skip to main content
Pratima Shrivastav (Slalom) 님이 #Visualforce에 질문했습니다
Hi.. I have just started learning jQuery in Vf page and was checking online resources . I cam accross these codes , needed some clarity on this.

<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-1.11.4.min.js')}"  />

<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-ui-1.8.6.custom.min.js')}"  />

<apex:stylesheet value="{!URLFOR($Resource.jQuery, '/css/ui-lightness/jquery-ui-1.8.6.custom.css')}"  />

  I have downloaded[ jquery-ui-1.11.4.custom.zip] and included as a static resource but I am not sure if I need to download something else as well?

Because in the example above there are 3 lines of code. Are they referring to the same jQuery zip folder?

Also please help me get some working example with jQuery in Visualforce page.
답변 8개
  1. 2016년 5월 5일 오전 8:37
    There are two kinds of people

    i) Who use static resources

    ii) Who source libraries from CDNs

    (there are significant number of people on both sides)

    I prefer CDNs for now.

    VF+jQuery (using CDN)

    <apex:page standardStylesheets="false" doctype="html-5.0">

    <head lang="en">

    <meta charset="utf-8"/>

    <meta name="viewport" content="width=device-width,initial-scale=1.0"/>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

    <style>

    ⌗sampleDiv{border:2px solid black;}

    .red{background-color:red;color:white;}

    </style>

    </head>

    <body>

    <div id="sampleDiv">

    click anywhere in this div

    </div>

    <br/><br/>

    <apex:form >

    <apex:inputText id="output" html-placeholder="Click here"/>

    </apex:form>

    <script>

    $(document).ready(function(){

    alert('Hello, jQuery');

    /*

    Notice the difference in the way element's Id have been referenced in jquery.

    for pure html tag use -> $('⌗idName')

    for VF tags use -> $('[id$=idName]')

    And for Classes

    pure html tag - > $('.className')

    VF tags -> $('[class$=className]')

    */

    $('⌗sampleDiv').click(function(){

    $(this).toggleClass('red');

    });

    $('[id$=output]').click(function(){

    alert('InputText clicked');

    });

    });

    </script>

    </body>

    </apex:page>

    Mark it as Best Answer, if it helps
0/9000