function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mehiya JetharamMehiya Jetharam 

Want to hide a picklist field Using JQuery.

I m trying to hide a picklist field in below Sample code:

<apex:page showheader="true" standardController="Merchandise__c">
<head>
<apex:includeScript value="{!$Resource.JqueryMin}"  />
<script>
   $j = jQuery.noConflict();
   $j(document).ready(function() {
   $j("#hide").click(function(){
        $j("#inpi").fadeOut('slow');
    });
    $j("#show").click(function(){
        $j("p").show();
    });
   });
</script>
</head>    
  
<body>
<apex:form >
<div id="inpi">
<apex:inputField value="{!Merchandise__c.PickList1__c}" />
</div>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</apex:form>
</body>
</apex:page>

When I click on hide button, it hide that field for a movement and again it appears automatically.
I think the page is getting refreshed or something else
Please provide me the solution.
Best Answer chosen by Mehiya Jetharam
Arunkumar RArunkumar R
Hi Mehiya,

Can you try the below code,
<apex:page showheader="true" standardController="Account">

<head>
<apex:includeScript value="{!$Resource.jQuery}" />
<script>
    $j = jQuery.noConflict();
    $j(document).ready(function() { 
$j("[id$='off']").click(function() {
    $j("[id$='disappear']").hide();
});

$j("[id$='on']").click(function() {
    $j("[id$='disappear']").show();
});

    });

</script>
</head>
<body>
<div id="disappear">
<apex:form>
<apex:inputField value="{!Account.Industry}" />
</apex:form>
</div>

<p id="off"> <button id="hide">Hide</button>

</p><p id="on"><button id="show">Show</button></p>

</body>

</apex:page>

Mark this as a solution, if this helpful to you..!