You need to sign in to do that
Don't have an account?
bonny mankotia
jquery in visualforce page not working
I use simple jquery code in vf page but its not work please help.
<apex:page standardController="Account" tabStyle="Account" sidebar="false">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("#Button").click(function()
{
$("#nm").hide();
});
});
</script>
</head>
<apex:form >
<apex:pageBlock title="Jquery Ex">
<apex:outputText value="{!account.name}" label="NAME" id="nm"/>
<apex:pageBlockButtons >
<apex:commandButton id="Button" value="Jquery"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
This is my code.
<apex:page standardController="Account" tabStyle="Account" sidebar="false">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function()
{
$("#Button").click(function()
{
$("#nm").hide();
});
});
</script>
</head>
<apex:form >
<apex:pageBlock title="Jquery Ex">
<apex:outputText value="{!account.name}" label="NAME" id="nm"/>
<apex:pageBlockButtons >
<apex:commandButton id="Button" value="Jquery"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
This is my code.
You can use <apex:commandButton styleClass="Button"/> instead and call it by $('.Button')
or you can reference the actual id using $Component variable, please refer to https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_best_practices_accessing_id.htm