-2

I want to blur an element on Window scroll Up event.. I am doing so using following Javascript

window.onscroll = function() {
    document.getElementById('HtmlIdGenerated').blur();
    document.getElementById('HtmlIdGenerated').style.color = 'red';
};


<div class= "random">
    <apex:selectList style="width:200;" >
        <apex:selectOptions value="{!randomVariable}">
        </apex:selectOptions>
    </apex:selectList>
</div>

But above Javascript does not work..Please Help Out! I want to close selectList upon Scroll.. To do so I am using blur() function of Javascript.. But blur is not working as selectList does not close upon scroll.. Color of list changes to red but list does not close upon scroll!

  • 1
    Those two pieces of code (Javascript and Visualforce) do not appear to have any connection to one another. Are you trying to access the generated HTML id of the <apex:selectOptions> component? – David Reed Jan 10 at 20:17
  • 1
    Could you please add more words, rather than code, to your question? Be specific about what you're hoping to achieve here and what happens instead. If you're actually trying to blur the selectList, read $Component – David Reed Jan 10 at 20:31
  • Possible duplicate of Cannot get the global variable $Component to return id – David Reed Jan 10 at 20:38
  • 2
    Please add all of this supporting information to your question, along with enough code for us to see what you're doing. Please stop posting comments. I will withdraw my proposed duplicate vote for now. – David Reed Jan 10 at 20:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.