+ Start a Discussion
EricBrownGTMEricBrownGTM 

jQuery not executing in VisualForce Page

I am using a VisualForce page for our Yammer embedded feeds and I am trying to modify some CSS via jQuery. I'm not exactly sure what is wrong, but the jQuery event won't execute and there for there is no CSS modification happening. Here is my code:

 

<apex:includeScript value="{!$Resource.YamEmbedJ}"/>
<script type="text/javascript">
$(window).load(function(){
$('yj-message-container').css('padding-left','40px');
});
</script>

 

The YamEmbedJ is a static resource of the jQuery library. I have also tried (document).ready event firing and no luck. Any assistance is appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
EricBrownGTMEricBrownGTM

Thank you everyone for the responses. I was able to actually use some custom CSS in a VisualForce page and just override the existing styles that were not working. Ended up not needed to use jQuery, but I will certainly keep the noConflict in mind for future applications. Thank you, again.

All Answers

chinnuchinnu

try using  jQuery.noConflict() along with your code

Rahul SharmaRahul Sharma

Use firebug or web developer tool for debugging jQuery or javascript issues.

dieffreidieffrei

You should pay attention for two key point:

- To use $.noConflict();

This way you dont have a conflict jquery vs salesforce libraries.

- Use jquery ready function:

jQuery.ready(function(){
   //to do
});

 Best

 

EricBrownGTMEricBrownGTM

Thank you everyone for the responses. I was able to actually use some custom CSS in a VisualForce page and just override the existing styles that were not working. Ended up not needed to use jQuery, but I will certainly keep the noConflict in mind for future applications. Thank you, again.

This was selected as the best answer