Sanjeev K Sanjeev K - 2 months ago 13
jQuery Question

add inline style to dynamically generated div using jquery

I am trying to add inline style to a div using jquery, following is the div as I inspect in firebug (attached below)

enter image description here

I want to keep the existing

CSS
as well, I just have to add
margin-left:0
and
margin-right:0
to the existing class, following jquery I've tried but no luck:

jQuery(document).ready(function($){
$(".testimonial_wrapper").css({'margin-left':'auto', 'margin-right':'auto'});
});


What are the other way to achieve? (please note that I am editing wordpress site and the divs are generated from page builders plugin)

Answer

I think you just have to erase the $ from function($) and change $to jQuery in the function itself:

jQuery(document).ready(function(){
   jQuery(".testimonial_wrapper").css({'margin-left':'auto', 'margin-right':'auto'});    
});